Skip to main content
Please help me figure out what I'm doing wrong.  I'm stumped.

I'm trying to log into salesforce from a google script.  when I run the auth function from my code I get this:

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

when I try to connect from curl I the same thing

curl command:

curl https://login.salesforce.com/services/oauth2/token -d 'grant_type=password&client_id=<client Id from my app i created in salesforce>&username=<my admin username in salesforce>&password=<my salesforce password><my salesforce security token>&client_secret=<client secred from app i created in salesforce>' -H "X-PrettyPrint: 1"

My google script code:

var url = "https://na14.salesforce.com/services/oauth2/token";

var payload =

{

"grant_type" : "password",

"client_id" : "<my app client id from the app I created in salesforce>",

"client_secret": "<my client secret from the app i created in salesforce>",

"username" : "<my sales force login email address>",

"password" : "<my salesforce password><my salesforce security token>"

};

var options =

{

"method" : "post",

"payload" : payload

};

var response = UrlFetchApp.fetch(url, options);

Here is how I set up my app:

OAuth 2.0 Username-Password Flow invalid_grant invalid_client

 
2 Antworten
  1. 6. Aug. 2015, 16:41
    changing the grant_type to authorization_code caused it to give me an error saying redirect_uri_mismatch.  

    when I add the redirect_uri (which shouldn't be required for this auth method)  it then says "invalid authorization code".
0/9000