8

Problem: trying to authenticate to a dev org using Session Id authentication and cURL fails when following the REST API Dev doc. The example in the doc provides the following, which fails (Quick Start pg:23):

curl https://login.salesforce.com/services/oauth2/token -d "grant_type=password" -d
"client_id=myclientid" -d "client_secret=myclientsecret" -d "[email protected]" -d
"password=mypassword123456"

Even after appending the security token to the password, the response is the same:

{"error":"invalid_grant","error_description":"authentication failure"}

1 Answer 1

12

The documentation has a bug in it. Following the documentation, your cURL command would look like this:

curl https://login.salesforce.com/services/oauth2/token -d "grant_type=password" -d 
"client_id=XXXXXX.YYYYY_ZZZZZ" -d "client_secret=000099990000" -d "[email protected]" -d 
"password=yourpasswordyoursecuritytoken"

It's missing the username= parameter. Change it to the following and it will work for you:

curl https://login.salesforce.com/services/oauth2/token -d "grant_type=password" -d 
"client_id=XXXXXX.YYYYY_ZZZZZ" -d "client_secret=000099990000" -d "[email protected]" -d 
"password=yourpasswordyoursecuritytoken"
5
  • 1
    Good find. Are you aware you can report this directly to Salesforce? Here is the html version of the page At the bottom of the page there is the section: Was this information helpful?, and the link Yes, except. Where you can put all the details you have posted in this question and answer. I don't know how proactive they are with the feedback they receive, so it may get ignored. But it's better than nothing Commented Dec 9, 2012 at 22:01
  • 1
    The feedback form directly logs a case with the doc writer team, and is by far the best way to give feedback & get the docs improved.
    – superfell
    Commented Dec 9, 2012 at 22:04
  • This is good to know. Thanks. I gave up on logging cases when they changed the rules to disallow dev orgs to file them. But I'll post this on the feedback form.
    – Adam
    Commented Dec 9, 2012 at 22:10
  • 1
    I stubmled across this today - proof positive that the documentation hasn't been corrected in 9 months Commented Sep 11, 2013 at 19:13
  • 1
    Too bad. I logged this on the feedback form back when it happened. This is why the StackExchange isn't going anywhere.
    – Adam
    Commented Sep 11, 2013 at 22:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .