-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Bearer token auhentication
- Loading branch information
Showing
4 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,20 @@ return [ | |
]; | ||
``` | ||
|
||
#### Authorization with Bearer token | ||
|
||
If you want to use the `Authorization` header with `Bearer` token, you should set the `header` key to `Authorization` and the `prefix` key to `Bearer` in your `config/apiTokenAuthenticator.php` file. | ||
|
||
```php | ||
<?php | ||
return [ | ||
'ApiTokenAuthenticator' => [ | ||
'header' => 'Authorization', | ||
'prefix' => 'Bearer', | ||
] | ||
]; | ||
``` | ||
|
||
## Authentication | ||
|
||
The plugin authentication workflow is the following. | ||
|
@@ -39,19 +53,19 @@ At your client appliacation you should send a POST request to `/users/login.json | |
|
||
```json | ||
{ | ||
"email": "[email protected]", | ||
"password": "rrd" | ||
"email": "[email protected]", | ||
"password": "rrd" | ||
} | ||
``` | ||
|
||
If the login was successful than you will get a response like this. | ||
|
||
```json | ||
{ | ||
"user": { | ||
"id": 1, | ||
"token": "yourSecretTokenComingFromTheDatabase" | ||
} | ||
"user": { | ||
"id": 1, | ||
"token": "yourSecretTokenComingFromTheDatabase" | ||
} | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters