3
votes

I am trying to access a salesforce sandbox account using a cURL request. I have created a similar cURL request using a separate salesforce developer account which has worked successfully; however, upon modifying the information from that request I get an error: invalid grant_type response. Below are the two request. The first is the working request and the second is the sandbox account which has the invalid grant_type error.

1 WORKS curl https://login.salesforce.com/services/oauth2/token -d grant_type=password -d "client_id=abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuv_ab" -d "client_secret=1234567891011121314" -d "[email protected]" -d "password=passwordxxxxxxxxxxxxxxxxxx" -H "X-Prettyprint:1"

2.DOES NOT WORK curl https://test.salesforce.com/services/oauth2/token -d grant_type=password -d "client_id=zxcvbnmasdfghjklqwertyuiopzxcvbnmasdfghjklqwertyuiop" -d "client_secret=7845679304-1945678" -d "[email protected] -d "password=passwordxxxxxxxxxxxxx” -H "X-Prettyprint:1"

where xxxxxxxx=security token

The two requests are almost identical but with different client_id client_secret username and password. They also have slightly different urls.

My guess is that there is something that I have to enable/disable from the sandbox account to allow these types of requests. However, I'm not sure and would appreciate help in determining a solution to this problem.

EDIT: When I make the request to the sandbox I get the follow message

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

1 Answers

0
votes

The client Id from a production organization won't work with a sandbox organization and vice versa.

So, you will need to setup a new app in a sandbox Org to get a client_id that will work in a sandbox.