简体   繁体   English

Laravel 5.4护照生成用于API身份验证的自定义访问令牌

[英]Laravel 5.4 passport to generate custom access token for API Authentication

We are trying to build an API service for our application which is going to be a single page application, and we came across Laravel Passport as mentioned in the documentation. 我们正在尝试为我们的应用程序构建一个API服务,该应用程序将成为一个单页应用程序,并且遇到了文档中提到的Laravel Passport。 We tried Password Grant Tokens which works well, but our requirement is to generate the access token using the data we get from LinkedIn after oAuth. 我们尝试了“ Password Grant Tokens ,该方法效果很好,但我们的要求是使用oAuth之后从LinkedIn获得的数据生成访问令牌。 For example, linkedin_id , email etc. Hence, we do not need a username and password fields (which are required for Password Grant Tokens). 例如, linkedin_idemail等。因此,我们不需要usernamepassword字段(密码授予令牌必填)。

We do not see any way to generate custom tokens in Laravel docs. 在Laravel文档中,我们看不到任何生成自定义标记的方法。 Has anyone tried this? 有人尝试过吗? Or, is there any alternative to proceed? 或者,是否有其他选择可以进行?

Have you tried the Laravel Socialite . 您尝试过Laravel Socialite吗 In Socialite you don't need username and password, only client_id , cliend_secret and redirect_url required. 在Socialite中,您不需要用户名和密码,仅需要client_idcliend_secretredirect_url

'linkedIn' => [
    'client_id' => 'your-linkedIn-app-id',
    'client_secret' => 'your-linkedIn-app-secret',
    'redirect' => 'http://your-callback-url',
],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM