6

This question already has an answer here:

I am attempting to obtain a token, using the Oauth 2 refresh token flow.

I am using the REST Console in Chrome to perform the following POST operation:

My URI is https://cs11.salesforce.com/services/oauth2/token

My Content-Type header is "application/json"

I am posting the following body (client id and secret omitted)

{
"client_id":"<supersecret>"
,"grant_type":"authorization_code"
,"client_secret":"<supersecret>"
,"redirect_uri": "https://"
}

From what I gather from the saleforce oauth2 refresh token flow documentation, this should work. However, I am getting the following error for a response:

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

Any thoughts on why the service doesn't like my grant_type parameter?

marked as duplicate by Boris Bachovski, Samuel De Rycke Feb 4 '15 at 23:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

9

Refresh flow uses application/x-www-form-urlencoded content type, not application/json, with a body of the form

grant_type=refresh_token&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&refresh_token=<REFRESH_TOKEN>

Here's a test I just ran, with credentials removed, and formatting added:

$ curl -d 'grant_type=refresh_token&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&refresh_token=<REFRESH_TOKEN>' https://login.salesforce.com/services/oauth2/token
{
    "id":"https://login.salesforce.com/id/00DE0000000HegHMAS/005E0000000HiFiIAK",
    "issued_at":"1409293734822",
    "scope":"id api refresh_token",
    "instance_url":"https://devorg-com-dev-ed.my.salesforce.com",
    "token_type":"Bearer",
    "signature":"ErVu6WnaaVlXrqLYItISuEm9/nHJIj9GgulS6wlMFnA=",
    "access_token":"<ACCESS_TOKEN>"
}
  • 3
    This is also the same for grant_type=authorization_code. You need to have the Content-Type header set to application/x-www-form-urlencoded and not application/json. – toobsco42 Jun 14 '15 at 9:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.