
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:
Here is how I set up my app: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);

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".