I am tying to obtain Access Token using Google Apps Script.
Ref: https://developers.docusign.com/platform/auth/jwt/jwt-get-token/
Using Postman, I can get the ACCESS TOKEN by posting a request using this URL: https://account-d.docusign.com/oauth/token
and this two fields in the body:
grant_type : urn:ietf:params:oauth:grant-type:jwt-bearerassertion : MY_JSON_WEB_TOKEN
How do I replicate tis in Apps script?
After endless hours of trial and error I still get this error: {"error":"invalid_grant","error_description":"unsupported_grant_type"}
The script:
function obtainAccessToken(){
const JWT = MY_JSON_WEB_TOKEN;
const URL = 'https://account-d.docusign.com/oauth/token';
const PARAMS = {
"muteHttpExceptions": true,
"method": "POST",
"contentType": "application/json",
"payload": {
"body":{
"grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer",
"assertion": JWT
}
}
};
return UrlFetchApp.fetch(URL, PARAMS);
}