【问题标题】:Get Userinfo from Oauth2 DocuSign API Implicit Grant从 Oauth2 DocuSign API 隐式授权获取用户信息
【发布时间】:2016-12-21 01:14:11
【问题描述】:

在收到来自隐式授予 oauth2 调用的访问令牌 (response_type=token) 后,我正尝试从 DocuSign API 获取用户信息。

我的代码如下所示:

request = $.ajax({
  type: 'GET',
     xhrFields: {withCredentials: true},
     beforeSend: function(xhr) {
      xhr.setRequestHeader('Authorization', DSaccesstoken);
       },
     url: DSuserurl 
   });

request.done (function (response, textStatus, jqXHR) {
 alert(response); 
 }

request.fail(function (jqXHR, textStatus, errorThrown){
   alert("Error retrieving DocuSign User Account Information: " + textStatus + " " + errorThrown + ". "); 
   });

});

几点... DSaccesstoken 是一个包含“从Docusign 接收到的承载访问令牌”的变量。代码执行成功,但响应数据在假设包含 json 时看起来像 html。我也试过datatype: 'json',但这也不起作用。我也尝试使用 headers: {'Authorization': DSaccesstoken} 而不是 beforeSend,但这也没有用。

我假设标头没有正确传递给 DocuSign,但我不能 100% 确定。有谁知道我做错了什么?仅供参考,我正在使用 PhoneGap Build 服务来创建移动应用程序。

【问题讨论】:

  • 抱歉,您需要提供更多信息。目前尚不清楚用户是否已正确验证。是否要求他登录?
  • 更多信息:
  • 更多信息:显然我的代码正确传递了授权标头。我的 DocuSign 沙箱和集成密钥被定义为“这是一个移动应用程序”。我的返回 uri 是 localhost/callback。问题是 DocuSign 抛出以下错误: {"errorCode":"RESOURCE_NOT_FOUND","message":"The URL provided does not resolve to a resource."} 有没有人在尝试使用隐式 oauth 检索用户信息时收到此错误?

标签: jquery ajax phonegap-build docusignapi


【解决方案1】:

两件事:

  1. 标头应为 {'Authorization': 'Bearer' + DSaccesstoken}。
  2. 由于 CORS 限制,客户端不允许使用 DocuSign Rest API。如果您从类似浏览器的一侧调用它,您可能会考虑设置代理服务器(例如使用节点)。该代理服务器将接收 ajax 调用并将它们重定向到 DocuSign API。您可以使用DocuSign official NPM package

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-21
    • 2022-10-20
    • 1970-01-01
    • 2016-05-05
    • 2020-12-07
    • 2019-12-31
    • 1970-01-01
    • 2016-05-24
    相关资源
    最近更新 更多