Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Salesforce by (11.9k points)

I'm trying to get an authorization token using the Username-Password flow (as described in the final section of this article).

I'm sending the following request (using Python's httplib, in case that's relevant):

https://login.salesforce.com/services/oauth2/token

POST data:

username=<un>&client_secret=<consumer_secret>&password=<pw+token>&grant_type=password&client_id=<consumer_key>

And getting the response:

400 Bad Request

{"error":"unsupported_grant_type","error_description":"grant type not supported"}

Is the password grant_type really unsupported, or am I missing something? It seems to give this error even when I'm sending a grant_type that definitely does work (such as authorization_code).

Note that I've tried the suggestions in the answer here, and they don't work for me.

1 Answer

0 votes
by (32.1k points)
edited by

Actually, this is because of the content-type header which has not been set to the correct value.

It should actually be set as:

application/x-www-form-urlencoded.

Also, you need to make sure that your parameters are correctly encoded.

To learn in-depth about Workflow in Salesforce, sign up for an industry based Salesforce developer certification.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...