我在从Implicit Grant oauth2调用收到访问令牌(response_type = token)后尝试从DocuSign API获取userinfo。
我的代码如下所示:
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服务创建移动应用程序。
答案 0 :(得分:0)
两件事: