我正在使用Google脚本绑定以获得访问令牌。
参考文献:https://developers.docusign.com/platform/auth/jwt/jwt-get-token/
使用Postman,我可以通过使用下面的URL:https://account-d.docusign.com/oauth/token和正文中的以下两个字段发送请求来获得访问令牌:
grant_type : urn:ietf:params:oauth:grant-type:jwt-bearerassertion : MY_JSON_WEB_TOKEN如何在Apps脚本中复制它?
经过无数个小时的尝试和错误,我仍然得到了这个错误:{"error":"invalid_grant","error_description":"unsupported_grant_type"}
剧本:
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);
}发布于 2021-09-15 09:24:47
这是正确的功能:
function obtainAccessToken(){
const JWT = MY_JSON_WEB_TOKEN;
const URL = 'https://account-d.docusign.com/oauth/token';
const PARAMS = {
"method": "POST",
"headers":{
"Accept": "application/json",
"contentType": "application/x-www-form-urlencoded"
},
"payload": {
"grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer",
"assertion": JWT
}
};
return UrlFetchApp.fetch(URL, PARAMS);
}https://stackoverflow.com/questions/69189577
复制相似问题