jeudi 21 mars 2019

Laravel passport: Manually create access token

I'm building an SPA using VueJS and Laravel.

I'm using Laravel passport for logins which works fine.

However I would like the ability to send users magic links to log in with. However I'm not sure how to create an access token without sending a request with the password to the oauth route.

It seems like it should be really easy to do, just inserting the right rows into oauth_access_tokens and oauth_refresh_tokens.

But i've been trawling through the code in the Passport repo and Google results and everything seems way more complicated.

What I would like is be able to do something like this:

$user = User::findFromMagicLink($link);
$token = $user->createAccessToken();
return response()->json(['access_token' => $token->token, 'refresh_token' => $token->refresh_token])

I'm guessing that's not possible otherwise it would be documented somewhere. But if it's something more complicated than that I can't figure it out.

Can anyone point me in the right direction?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire