Reputation: 527
When I request an access token at oauth/token
using the password grant, I get a token back. However this token is the same every time and doesn't match any token in the database. Where are these tokens stored? And how can I use this token to retrieve my user data in an AJAX call?
Upvotes: 2
Views: 5178
Reputation: 31
After installing passport. you need to run command php artisan migrate
.
this command will create 4 tables.
oauth_access_tokens
oauth_auth_codes
oauth_personal_access_clients
oauth_refresh_tokens
PASSPORT ACCESS TOKENS ARE STORED IN oauth_access_tokens
table.
in this table id
column is used to store token.
Upvotes: 3
Reputation: 472
The token generated by oauth server is unique and you have to store it somewhere like cookies or user table. You can pass the access_token through authorization header.
Ajax call :
var token = "Your access_token";
$.ajax({
url:"someurl.com/api/auth/getuser",
dataType: 'json',
headers: {
'Authorization': 'Bearer ' + token
},
success: function(data, status) {
return console.log("The returned data", data);
}
});
Upvotes: 0