首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DocuSignAPI REST --为什么我的OAuth请求不能通过?

问DocuSignAPI REST --为什么我的OAuth请求不能通过?
EN

Stack Overflow用户
提问于 2014-03-06 17:43:44
回答 1查看 525关注 0票数 2

我试图使用DocuSign REST并创建一个OAuth请求来执行(SOBO)的发送。虽然我不能完成第一项任务,但它给了我一个糟糕的要求。我做错了什么?

带有标头的请求:

代码语言:javascript
复制
POST https://demo.docusign.net/restapi/v2/oauth2/token

Accept: application/xml
Content-Type: application/xml
Content-Length: {length of body}

请求体

代码语言:javascript
复制
<OAuthTokenRequest>
  <grant_type>password</grant_type>
  <client_id>{IntegratorKey}</client_id>
  <username>test@email.com</username>
  <password>{Password}</password>
  <scope>api</scope>
</OAuthTokenRequest>

错误响应:

代码语言:javascript
复制
400 Bad Request 

<oauthErr xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <error>invalid_request</error>
  <error_description>An OAuth2 error occurred:</error_description>
</oauthErr>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-06 17:43:44

尽管大多数DocuSign REST都接受XML格式设置,但OAuth请求必须以x-www-form-urlencoded格式发出。

将请求更改为以下内容:

带有标头的请求:

代码语言:javascript
复制
POST https://demo.docusign.net/restapi/v2/oauth2/token

Accept: application/xml
Content-Type: application/x-www-form-urlencoded
Content-Length: {length of body}

请求主体:

代码语言:javascript
复制
grant_type=password&client_id={IntegratorKey}&username=test@email.com&password={Password}&scope=api

示例响应:

代码语言:javascript
复制
200 OK

<oauthAccess xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <access_token>{Access Token}</access_token>
  <scope>api</scope>
  <token_type>bearer</token_type>
</oauthAccess>

More information can be obtained in this documentation.

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22232036

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档