2

curl -v https://test.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=" -d "client_secret=" -d "username=" -d "password="

I've tried this with instance name instead of test or login. I also tried with my security token appended to the end of the password.

I'm 100% positive that I've using the client_id, client_secret, and username for the sandbox that I'm testing with.

response:

* Hostname was NOT found in DNS cache
*   Trying 96.43.145.28...
* Connected to test.salesforce.com (96.43.145.28) port 443 (#0)
* TLS 1.2 connection using TLS_RSA_WITH_AES_256_CBC_SHA
* Server certificate: test.salesforce.com
* Server certificate: VeriSign Class 3 International Server CA - G3
* Server certificate: VeriSign Class 3 Public Primary Certification Authority - G5
> POST /services/oauth2/token HTTP/1.1
> User-Agent: curl/7.37.1
> Host: test.salesforce.com
> Accept: */*
> Content-Length: 214
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 214 out of 214 bytes
< HTTP/1.1 400 Bad Request
< Date: Tue, 11 Nov 2014 14:28:04 GMT
< Set-Cookie: BrowserId=SIIHl7AKTn2BgoK5jwajtg;Path=/;Domain=.salesforce.com;Expires=Sat, 10-Jan-2015 14:28:04 GMT
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, no-store
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
<
* Connection #0 to host test.salesforce.com left intact
{"error_description":"authentication failure","error":"invalid_grant"}
7

I have seen client id's and some passwords which need to be urlencoded/escaped to work well with curl.

Maybe you should try the --data-urlencode option (source: https://stackoverflow.com/questions/10060093/special-characters-like-and-in-curl-post-data )

Example usage would be: curl -v https://test.salesforce.com/services/oauth2/token -d "grant_type=password" --data-urlencode "client_id=" -d "client_secret=" -d "username=" --data-urlencode 'password='

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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