首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“范围必须是API”在发出代表Curl请求时

问“范围必须是API”在发出代表Curl请求时
EN

Stack Overflow用户
提问于 2016-12-14 01:46:45
回答 1查看 290关注 0票数 1

下面是文档:https://www.docusign.com/developer-center/explore/features/sobo

我已经构建了以下curl请求:

代码语言:javascript
复制
curl --request POST \
  --url 'https://demo.docusign.net/restapi/v2/oauth2/token?grant_type=password&client_id=<my integrator key>username=<my email>&password=<my password>&scope=api' \
  --header 'accept: application/json' \
  --header 'cache-control: no-cache' \
  --header 'content-length: 0' \
  --header 'content-type: application/x-www-form-urlencoded' \

然而,当我运行这个程序时,我会得到这样的响应。

代码语言:javascript
复制
{
  "error": "invalid_scope",
  "error_description": "Scope must be 'api'."
}

当我在nodejs中运行类似的调用时,我会得到相同的结果。

代码语言:javascript
复制
var request = require("request");

var options = { method: 'POST',
  url: 'https://demo.docusign.net/restapi/v2/oauth2/token',
  qs:
   { grant_type: 'password',
     client_id: '',
     username: '',
     password: '',
     scope: 'api' },
  headers:
   { 'cache-control': 'no-cache',
     'content-length': '0',
     accept: 'application/json',
     'content-type': 'application/x-www-form-urlencoded' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

我也尝试使用这个url,但得到一个“对象移动”响应:https://account-d.docusign.com/restapi/v2/oauth2/token

这对我来说毫无意义,因为我在网址的末尾有"scope=api“。这里发生什么事情?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-16 22:47:51

经过几天的搜索,我发现了这个(矛盾的)文档:https://docs.docusign.com/esign/guide/authentication/sobo.html

原来,您不需要像我共享的第一个链接中所概述的那样,执行多步OAuth令牌过程。您只需在中使用“SendOnBehalfOf”参数即可。

直接从该链接中获取,它将如下所示:

代码语言:javascript
复制
{
  "Username": "nat.irving@example.com",
  "Password": "S3cre+p455w0Rd",
  "IntegratorKey": "230546a7-9c55-40ad-8fbf-af205d5494ad",
  "SendOnBehalfOf": "ruggiero.gardener@example.com"
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41133501

复制
相关文章

相似问题

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