Laravel Passport: Create access token manually

走远了吗. 提交于 2019-12-07 05:57:55

问题


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.


回答1:


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);


来源:https://stackoverflow.com/questions/47903457/laravel-passport-create-access-token-manually

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!