I'm trying to find a way to create an access token manually in Laravel 5.5 using Passport and can't seem to figure it out.
I have 2 applications, one that holds the frontend and one api. The user receives an invitation via mail, and when he accesses the link, i wish to create the auth token and send it back in the response.
Any ideas on how to do this ? Thanks.
Requesting Tokens Once you have created a password grant client, you may request an access token by issuing a POST request to the /oauth/token route with the user's email address and password. Remember, this route is already registered by the Passport::routes method so there is no need to define it manually.
You can store this token in local storage. This token is also stored in the oauth_access_tokens table. We will be sending a GET request to your URL and we need to send it token as Authorization Header. Above way successive technologies can do API authentication in Laravel Application with a passport.
Passport uses JWT authentication as standard but also implements full OAuth 2.0 authorization.
Solved it myself. It seems that the HasApiTokens trait that you put on the users model has a method to create a token
$user->createToken($name, $scopes);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With