Laravel Passport:手动创建访问令牌 [英] Laravel Passport: Create access token manually

查看:26
本文介绍了Laravel Passport:手动创建访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一种使用 Passport 在 Laravel 5.5 中手动创建访问令牌的方法,但似乎无法弄清楚.

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.

我有 2 个应用程序,一个包含前端,一个 api.用户通过邮件收到邀请,当他访问链接时,我希望创建身份验证令牌并将其在响应中发回.

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.

推荐答案

自己解决了.似乎您在用户模型有一个创建令牌的方法

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

这篇关于Laravel Passport:手动创建访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆