OAuth 2 身份验证中 grant_type 参数的用途是什么
What is the purpose of grant_type parameter in OAuth 2 Authentication
我在 Lumen 微框架中使用 OAuth 2 身份验证。现在我使用的 grant_type
值是 password
。如果我使用不同的东西,它会抛出 unsupported_grant_type
。我想知道使用 grant_type
的目的是 password
grant_type
URL 参数是 OAuth2 RFC for 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 所必需的,因此您必须将其指定为值 password
。
来自 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.
grant_type=password
表示您正在向 /token
端点发送用户名和密码。如果您使用 Authorization Code Grant 流,则可以使用值 authorization_code
。但是你不会发送用户名+密码对,而是在用户身份验证后从 OAuth2 服务器收到的代码。该代码是一个任意字符串 - 不是人类可读的。在 RFC 的工作流程图中很好地展示了它。
在 OAuth 2.0 中,术语“授权类型”是指应用程序获取访问令牌的方式。 OAuth 2.0 定义了几种授权类型,包括授权代码流。 OAuth 2.0 扩展还可以定义新的授权类型。
我在 Lumen 微框架中使用 OAuth 2 身份验证。现在我使用的 grant_type
值是 password
。如果我使用不同的东西,它会抛出 unsupported_grant_type
。我想知道使用 grant_type
的目的是 password
grant_type
URL 参数是 OAuth2 RFC for 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 所必需的,因此您必须将其指定为值 password
。
来自 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.
grant_type=password
表示您正在向 /token
端点发送用户名和密码。如果您使用 Authorization Code Grant 流,则可以使用值 authorization_code
。但是你不会发送用户名+密码对,而是在用户身份验证后从 OAuth2 服务器收到的代码。该代码是一个任意字符串 - 不是人类可读的。在 RFC 的工作流程图中很好地展示了它。
在 OAuth 2.0 中,术语“授权类型”是指应用程序获取访问令牌的方式。 OAuth 2.0 定义了几种授权类型,包括授权代码流。 OAuth 2.0 扩展还可以定义新的授权类型。