Expand my Community achievements bar.

Oauth2 "Invalid grant_type parameter value" error when requesting access token using Password Grant Type

Avatar

Level 2

Hello,

 

I'm trying to get access token using Password Grant Type:

 

curl --location --request POST 'http://<HOST>:<PORT>/oauth/token?username=<USERNAME>&password=<PASSWORD>&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&grant_type=password&redirect_uri=<REDIRECT_URI>' --header 'Content-Type: application/x-www-form-urlencoded'

 

 

However, that results in the following error:

 

{"error_description":"Invalid grant_type parameter value","error":"invalid_request"}curl: (18) transfer closed with outstanding read data remaining

 

 

AEM ver is 6.5

 

Any help appreaciated.

2 Replies

Avatar

Community Advisor

Hello @dwid1 

 

Please try with following grant_type:

client_credentials

refresh_token

authorization_code


Aanchal Sikka

Avatar

Level 2

Hello @aanchal-sikka

I cannot use refresh_token / authorization_code as they do not exchange the user’s username and password for an access token.

 

These are the grant types to exchange the user’s username and password for an access token:
https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/ or 
https://www.oauth.com/oauth2-servers/access-tokens/password-grant/

 

However, both the grant types:
password,
client_credentials

result in the same error:

 

{"error_description":"Invalid grant_type parameter value","error":"invalid_request"}curl: (18) transfer closed with outstanding read data remaining