I'm trying to connect a Google spreadsheet to snov.io service using an API POST request, they have provided a Python code as example and I have tried to run the google script below based on it, but without success. Any ideas? Thank you :)
Python (provided by the company)
def get_access_token():
params = {
'grant_type':'client_credentials',
'client_id':'c57a0459f6t141659ea75cccb393c111',
'client_secret': '77cbf92b71553e85ce3bfd505214f40b'
}
res = requests.post('https://api.snov.io/v1/oauth/access_token', data=params)
resText = res.text.encode('ascii','ignore')
return json.loads(resText)['access_token']
Google Script (Error:SyntaxError:'Unexpected end of JSON input')
var params = {
'grant_type':'client_credentials',
'client_id':'c57a0459f6t141659ea75cccb393c111',
'client_secret': '77cbf92b71553e85ce3bfd505214f40b',
'method':'post'
}
var url = 'https://api.snov.io/v1/oauth/access_token';
var response = UrlFetchApp.fetch(url,params)
var json = response.getContentText();
obj = JSON.parse(json);
token = obj.result.access_token;
return token