【发布时间】:2021-04-16 17:50:05
【问题描述】:
参考:https://developers.docusign.com/platform/auth/authcode/authcode-get-token/
我在第 2 步:获取访问令牌
时遇到问题我正在尝试获取访问令牌。但是我收到以下错误:
{
"error": "invalid_grant",
"error_description": "unsupported_grant_type"
}
无论是使用 c# 代码还是使用 PostMan,我都会收到上述错误。
在邮递员中 网址:https://account-d.docusign.com/oauth/token 方法:发布
标题
Authorization: BASIC BASE64_COMBINATION_OF_INTEGRATION_AND_SECRET_KEYS
Content_Type: application/json;charset=utf-8
Body:我试过form-data、x.www.form-urlencoded、raw...都是一样的
grant_type: authorization_code
code: My_AUTHORIZATION_CODE
当我获得授权码时,我也尝试在回调页面中获取访问令牌。
protected void Page_Load(object sender, EventArgs e)
{
var url = ConfigurationManager.AppSettings["DocuSign.TokenEndPoint"];
var data = $"grant_type=authorization_code=&{Request.QueryString["Code"]}";
WebRequest req = WebRequest.Create(url);
req.Method = "POST";
req.ContentLength = data.Length;
req.ContentType = "application/json; charset=UTF-8";
UTF8Encoding enc = new UTF8Encoding();
var code64 = Convert.ToBase64String(enc.GetBytes($"{ConfigurationManager.AppSettings["DocuSign.ClientId"]}:{ConfigurationManager.AppSettings["DocuSign.ClientSecret"]}"));
req.Headers.Add("Authorization", "Basic " + code64);
using (Stream ds = req.GetRequestStream())
{
ds.Write(enc.GetBytes(data), 0, data.Length);
}
WebResponse wr = req.GetResponse();
Stream receiveStream = wr.GetResponseStream();
StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
string content = reader.ReadToEnd();
Response.Write(content);
}
【问题讨论】:
-
这看起来像 C#,试试快速入门怎么样?它会给你一个 ZIP 文件,该文件已经配置了你的身份验证,而且一切正常。 developers.docusign.com/docs/esign-rest-api/quickstart
标签: docusignapi