laravel OAuth 2 身份验证中 grant_type 参数的用途是什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45055277/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the purpose of grant_type parameter in OAuth 2 Authentication
提问by Hariharan
I am using OAuth 2 Authentication in Lumen microframework. Right now i am using the grant_type
value is password
. It throws unsupported_grant_type
, If i am using something different. I want to know the purpose of using grant_type
is password
我在 Lumen 微框架中使用 OAuth 2 身份验证。现在我使用的grant_type
值为password
. unsupported_grant_type
如果我使用不同的东西,它会抛出。我想知道使用的目的grant_type
是password
回答by Ján Hala?a
The grant_type
URL parameter is required by OAuth2 RFCfor the /token
endpoint, which exchanges a grant for real tokens. So the OAuth2 server knows what you are sending to it. You are using the Resource Owner Password Credentials Grant, so you must specify it with the value password
.
该grant_type
URL参数所要求的OAuth2 RFC的/token
终点,这对交换令牌真正的授权。所以 OAuth2 服务器知道你向它发送了什么。您正在使用Resource Owner Password Credentials Grant,因此您必须使用值指定它password
。
From the OAuth2 RFC:
来自 OAuth2 RFC:
An authorization grant is a credential representing the resource owner's authorization (to access its protected resources) used by the client to obtain an access token.
授权许可是一种凭证,表示客户端用于获取访问令牌的资源所有者授权(访问其受保护的资源)。
The grant_type=password
means that you are sending a username and a password to the /token
endpoint. If you used the Authorization Code Grantflow, you could use the value authorization_code
. But then you don't send the username+password pair, but a code received from the OAuth2 server after user authentication. The code is an arbitrary string - not human readable. It's nicely shown in the workflow diagrams in the RFC.
这grant_type=password
意味着您正在向/token
端点发送用户名和密码。如果您使用了授权代码授予流程,则可以使用值authorization_code
。但是随后您不会发送用户名+密码对,而是在用户身份验证后从 OAuth2 服务器接收到的代码。代码是一个任意字符串 - 不是人类可读的。它很好地显示在 RFC 的工作流图中。