Laravel 5.4 Passport Implicit Grant Tokens返回一个带访问令牌的URL,如何使用json返回?

时间:2017-03-14 03:03:11

标签: json laravel

2 个答案:

答案 0 :(得分:0)

你的意思是

return response()->json('http://passport.dev/oauth/authorize?'.$query);

答案 1 :(得分:0)

通过使用Passport::enableImplicitGrant()并包括response_type => 'token',您将明确告诉oAuth使用ImplicitGrant流,根据OAuth规范,该流将在片段化的url中返回access_token(在#部分之后)。如果您希望使用JSON响应,则这是正确的行为,您可以考虑使用其他oAuth grant_types。

请参阅下面的链接以获取有关隐式授权流程的进一步说明

https://tools.ietf.org/html/rfc6749#section-4.2

https://oauth.net/2/grant-types/implicit/