san san
san san

Reputation: 53

Postman oAuth2 error Unauthorized grant type

I have an application that use oAuth2, and I try to request an access token from terminal with this command

curl -X POST -vu clientapp:123456 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=spring&username=roy&grant_type=password&scope=read%20write&client_secret=123456&client_id=clientapp"

it works fine and I get a response like this

{"access_token":"29c4c218-1d9a-4d2d-abe3-197bc2969679","token_type":"bearer","refresh_token":"6b7ffda7-4652-4197-b8e9-c80635eb9143","expires_in":38630,"scope":"read write"}

but the problem is when I try to request an access token via postman is always get this error:

Handling error: InvalidClientException, Unauthorized grant type: client_credentials

how do get access token via postman like I get token via curl command?

Upvotes: 5

Views: 19327

Answers (2)

Vin
Vin

Reputation: 31

Please see the screenshot attached.

enter image description here

In the body, Just select x-www-form-urlencoded and then provide the grant_type and client_credentials in the as key value pair.

Upvotes: 3

Parth Solanki
Parth Solanki

Reputation: 3448

check the attached image, you need to pass like below .

And in header you also need to pass Authorization header.

Authorization --> Basic Y2xpZW50OnNlY3JldA==

enter image description here

This will work for me , I hope this will help you .

Upvotes: 4

Related Questions