Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of grant_type parameter in OAuth 2 Authentication

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

like image 696
Hariharan Avatar asked Jul 12 '17 10:07

Hariharan


People also ask

What is Grant_type in oauth2?

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.

What is the purpose of Redirect_uri?

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.

What is Grant_type Authorization_code?

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.

What is Grant_type password?

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.


2 Answers

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.

like image 200
Ján Halaša Avatar answered Oct 20 '22 19:10

Ján Halaša


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.

like image 22
Bill Avatar answered Oct 20 '22 19:10

Bill