Cannot get an access token - unknown grant type



I am trying to get access token for a user, but I keep receiving "status":"BAD_GRANT_TYPE","message":"missing or unknown grant type". I have tried encoding query params or passing them as one json param, but nothing worked.

payload = {
    'grant_type': 'authorization_code',
    'client_id': 'f6***',
    'client_secret': 'f2***',
    'redirect_uri': 'https://sc***/',
    'code': '5f***'
}'', params=payload)


@esthom Are you setting your content-type in the headers? Should be

Content-Type: application/x-www-form-urlencoded;charset=utf-8

Sometimes not having the correct content-type can throw off a server trying to read your request.


Thanks @pmanca, that worked fine!


@pmanca I seem to be having the same issue. Not sure why however. the header on postman is as you describe it along with the body data.

header image:
body image:

Any ideas would be greatly appreciated.



@sphot Can you send along the full image of your body?


Hi, I'm having the same problem with Postman, how could you solve it?


But not working for me even after chnaging the order as follows:

And adding " Content-Type: application/x-www-form-urlencoded;charset=utf-8"



Welcome, @brij.

Per this documentation, you must include grant_type, client_id, client_secret, redirect_uri, and code in the request body.

You are trying to include those parameters as headers, but the only header should be Content-Type: application/x-www-form-urlencoded;charset=utf-8.


Not it says "{
"status": "BAD_CLIENT_ID",

"message": "missing or unknown client id","

I think it worked now I have to get new client id.

But the same client id was used to get the code.


Hi, @brij.

Are you still experiencing this error? I was unsure whether your last post said you got it working.

The client_id you should use is located in your app settings. If you need help finding this, please share your developer Hub ID and app ID.


It worked now, please remove my last response.


Glad to hear it, @brij! I've deleted the post you requested.


@Isaac_Takushi Thanks a lot!