Skip to content

Commit 144aa32

Browse files
lonnieezellkenjis
andauthored
Apply suggestions from code review
Co-authored-by: kenjis <kenji.uui@gmail.com>
1 parent b37ce68 commit 144aa32

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/guides/api-tokens.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Access Tokens can be used to authenticate users for your own site, or when allow
44

55
Tokens are issued with the `generateAccessToken()` method on the user. This returns a `CodeIgniter\Shield\Entities\AccessToken` instance. Tokens are hashed using a SHA-256 algorithm before being saved to the database. The access token returned when you generate it will include a `raw_token` field that contains the plain-text, un-hashed, token. You should display this to your user at once so they have a chance to copy it somewhere safe, as this is the only time this will be available. After this request, there is no way to get the raw token.
66

7-
The `generateAccessToken` method requires a name for the token. These are free strings and are often used to identify the user/device the token was generated from, like 'Johns MacBook Air'.
7+
The `generateAccessToken()` method requires a name for the token. These are free strings and are often used to identify the user/device the token was generated from, like 'Johns MacBook Air'.
88

99
```php
1010
$routes->get('/access/token', static function() {
@@ -31,9 +31,10 @@ Access tokens can be given `scopes`, which are basically permission strings, for
3131
return $user->generateAccessToken('token-name', ['users-read'])->raw_token;
3232
```
3333

34-
NOTE: At this time, scope names should avoid using a colon (:) as this causes issues with the route filters being correctly recognized.
34+
> **Note**
35+
> At this time, scope names should avoid using a colon (`:`) as this causes issues with the route filters being correctly recognized.
3536
36-
When handling incoming requests you can check if the token has been granted access to the scope with the `tokenCan` method.
37+
When handling incoming requests you can check if the token has been granted access to the scope with the `tokenCan()` method.
3738

3839
```php
3940
if ($user->tokenCan('users-read')) {
@@ -73,4 +74,5 @@ $routes->get('users', 'UserController::list', ['filter' => 'tokens:users-read'])
7374

7475
When the filter runs, it checks the `Authorization` header for a `Bearer` value that has the raw token. It then hashes the raw token and looks it up in the database. Once found, it can determine the correct user, which will then be available through an `auth()->user()` call.
7576

76-
Note: Currently only a single scope can be used on a route filter. If multiple scopes are passed in, only the first one is checked.
77+
> **Note**
78+
> Currently only a single scope can be used on a route filter. If multiple scopes are passed in, only the first one is checked.

0 commit comments

Comments
 (0)