So I'm building a connector using the developer IDE, but I just can't seem to get the authentication script working with the 'httprequest' library (I believe it's domo built-in?)
The connector will serve to pull data from my API and the API uses Oauth2.0. However, I'm having trouble getting a token through domo, but I can easily do it through a curl or by using Postman API tool.
I'm getting a HTTP 415 - Unsupported Media Type Error
Here's the code below:
var client_id = '4969e1ea-71b9-3267-ae7d-4ce0ac6bfa28';
var client_secret = '*****************************';
var user = '*********';
var pass = '*********';
var postData =
{
data: {
'grant_type': 'password',
'username': user,
'password': pass,
'client_id': client_id,
'client_secret': client_secret,
'scope': 'internal'
}
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
};
var res = httprequest.post('https://rest.synthesio.com/security/v1/oauth/token', postData);
DOMO.log('res: ' + res);
Please let me know if you have a different way of approaching this. I've tried to remove the headers within the postdata object itself as well as removing the data variable, leaving the attributes as is, too.
Thanks,
Adi