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
What is an OAuth grant type? The OAuth grant type determines the exact sequence of steps that are involved in the OAuth process. The grant type also affects how the client application communicates with the OAuth service at each stage, including how the access token itself is sent.
A redirect URI, or reply URL, is the location where the authorization server sends the user once the app has been successfully authorized and granted an authorization code or access token.
grant_type=authorization_code - This tells the token endpoint that the application is using the Authorization Code grant type. code - The application includes the authorization code it was given in the redirect. redirect_uri - The same redirect URI that was used when requesting the code.
The resource owner password (or "password") grant type is mostly used in cases where the app is highly trusted. In this configuration, the user provides their resource server credentials (username/password) to the client app, which sends them in an access token request to Apigee Edge.
The grant_type
URL parameter is required by 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, so you must specify it with the value password
.
From the 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 Grant flow, 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.
in OAuth 2.0, the term “grant type” refers to the way an application gets an access token. OAuth 2.0 defines several grant types, including the authorization code flow. OAuth 2.0 extensions can also define new grant types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With