You need to sign in to do that
Don't have an account?
Zachariah Rosenberg
Google Apps Script/SF REST API Authentication problem
Hello,
I'm trying to write an REST aPI call from my google sheets. I originally wrote the call in python, which worked wonderfully. Porting it to JS on google apps, I'm getting a "grant_type" error:
Produces:
I saw someone else on this board had a similar problem (https://developer.salesforce.com/forums/#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F00000009At3IAE), and he just went the OAuth route. I'd prefer not to, if possible.
What might the issue be?
Thank you!
I'm trying to write an REST aPI call from my google sheets. I originally wrote the call in python, which worked wonderfully. Porting it to JS on google apps, I'm getting a "grant_type" error:
function authenticateSF(){ var url = 'https://login.salesforce.com/services/oauth2/token'; var options = { grant_type:'password', client_id:'XXXXXXXXXXX', client_secret:'111111111111', username:'ITSME@smee.com', password:'smee' }; var results = UrlFetchApp.fetch(url, options); }
Produces:
Request failed for https://login.salesforce.com/services/oauth2/token returned code 400. Truncated server response: {"error_description":"grant type not supported","error":"unsupported_grant_type"} (use muteHttpExceptions option to examine full response) (line 12, file "Code")
I saw someone else on this board had a similar problem (https://developer.salesforce.com/forums/#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F00000009At3IAE), and he just went the OAuth route. I'd prefer not to, if possible.
What might the issue be?
Thank you!
Zachariah Rosenberg
Google's UrlFetchApp object automatically defaults to a GET request. To authenticate, you have to explicitly set in the options the method "post":