You need to sign in to do that
Don't have an account?
Ignacio Sales 1
Error "unsupported_grant_type" when getting OAuth token for a connected app. Single Sign on and custom domain enabled.
We are getting the error "unsupported_grant_type" when getting an OAuth token for a connected app. The connected app is installed on a Org with Single Sign on and which uses a custom domain.
When starting the OAuth 2.0 Web Server Flow for Web App Integration, the user is directed to their custom domain login url, they log in successfully, and are presented with the approval page, where they confirm that they grant the required access.
Then, when we request the token, we receive the error:
Client error: `POST https://<customercustomdomain>.lightning.force.com//services/oauth2/token` resulted in a `400 Bad Request` response:
{"error":"unsupported_grant_type","error_description":"grant type not supported"}
This same OAuth flow is working with all our other customers, using the same grant type (which is authorization_code).
We've seen quite a lot of posts which talk about this error, but they all seem to refer to missing or incorrect headers, in situations in which the OAuth flow does not work at all. But in our case, it works in all Orgs, except for this particular one.
Any ideas / help would be much appreciated.
When starting the OAuth 2.0 Web Server Flow for Web App Integration, the user is directed to their custom domain login url, they log in successfully, and are presented with the approval page, where they confirm that they grant the required access.
Then, when we request the token, we receive the error:
Client error: `POST https://<customercustomdomain>.lightning.force.com//services/oauth2/token` resulted in a `400 Bad Request` response:
{"error":"unsupported_grant_type","error_description":"grant type not supported"}
This same OAuth flow is working with all our other customers, using the same grant type (which is authorization_code).
We've seen quite a lot of posts which talk about this error, but they all seem to refer to missing or incorrect headers, in situations in which the OAuth flow does not work at all. But in our case, it works in all Orgs, except for this particular one.
Any ideas / help would be much appreciated.
Will write it up here in case it helps someone with a similar problem.
The problem was that we were getting a 302-Redirect response from the call to get the OAuth token. Our http client was following the redirect with GET, instead of with POST, which was the method used on the first request. Configuring the client to use "strict" mode changed this behaviour, so the redirect URL was requested with POST, and the token was obtained successfully.
All Answers
Check Endpoint URL since issue is only with particular org.
Also check http Post payload format using POSTMAN and you should be able to fix it.
Hope above information was helpful.
Please mark as Best Answer so that it can help others in the future.
Thanks,
Vinay Kumar
Will write it up here in case it helps someone with a similar problem.
The problem was that we were getting a 302-Redirect response from the call to get the OAuth token. Our http client was following the redirect with GET, instead of with POST, which was the method used on the first request. Configuring the client to use "strict" mode changed this behaviour, so the redirect URL was requested with POST, and the token was obtained successfully.