XSRF with AngularJS: DocuSign API Embedded View Client-Side
XSRF with AngularJS: DocuSign API Embedded View Client-Side implementation
我有一个AngularJS应用程序,该应用程序利用DocuSign Embedded Signing REST API在用户完成表单后打开一个包含嵌入文档的选项卡。
我已经浏览了StackOverflow的一些主题来提供帮助,但我找不到任何像我的实现一样的东西。
我在登录时继续收到 401 错误,我很确定这是因为 CORS 被阻止。任何帮助不胜感激!
这是我的DocuSign工厂:
app.factory('dsFactory', function($http) {
return {
login: function(templateId) {
return $http({
url: 'https://demo.docusign.net/restapi/v2/login_information',
method: 'GET',
params: {
'X-DocuSign-Authentication': {
'DocuSignCredentials': {
'UserName': 'xxx',
'Password': 'xxx',
'IntegratorKey': 'xxx'
}
}
}
});
},
envelope: function(baseUrl, templateId, recipientName, templateRoleName) {
var url = baseUrl + "/envelopes";
return $http({
url: url,
method: 'POST',
params: {
"emailSubject": "DocuSign API call - Embedded Sending Test",
"templateId": templateId,
"templateRoles": [{
"email": "xxx",
"name": recipientName,
"roleName": templateRoleName
}],
"status": "sent"
}
});
},
getUrl: function(baseUrl, envelopeId, recipientName) {
var url = baseUrl + "/envelopes/" + envelopeId + "/views/recipient";
return $http({
url: url,
method: 'POST',
params: {
"returnUrl": "http://www.docusign.com/devcenter",
"authenticationMethod": "email",
"email": "xxx",
"userName": recipientName
}
});
}
};
});
以下是使用嵌入式文档视图打开新选项卡的承诺链:
// Elaborate promise chain for DocuSign login and document url retrieval
loginPromise = dsFactory.login($scope.templateId);
loginPromise.then(
function(payload) {
$scope.dsBaseUrl = payload.data.loginAccounts[0].baseUrl;
envelopePromise = dsFactory.envelope($scope.dsBaseUrl, $scope.templateId, $scope.businessName, 'Signer');
envelopePromise.then(
function(payload) {
$scope.dsEnvelopeId = payload.data.envelopeId;
urlPromise = dsFactory.getUrl($scope.dsBaseUrl, $scope.dsEnvelopeId, $scope.businessName);
urlPromise.then(
function(payload) {
$scope.dsCompleteUrl = payload.data.returnUrl;
window.open($scope.dsCompleteUrl);
},
function(errorPayload) {
console.log('retrieve DS url failed' + ''n');
console.log('Status: ' + errorPayload.status);
}
);
},
function(errorPayload) {
console.log('retrieve DS envelopeId failed' + ''n');
console.log('Status: ' + errorPayload.status);
}
);
},
function(errorPayload) {
console.log('DS login failed' + ''n');
console.log('Status: ' + errorPayload.status);
}
);
关于如何使此集成正常工作的任何想法或帮助?
也许与标题有关?
此问题并非特定于 Angular。
-
如果您可以使用回调或要求目标域在"访问控制-允许源"标头中添加您的域。对于您的具体问题,我认为您不能要求DocuSign这样做。它给你留下#2。
-
您可以从服务器端调用 API。
Angularjs https (browser)->your server->DocuSign API>your server->browser
相关文章:
- 谷歌地图API v3:Initial View is Fine,but Gray Box with No Map if
- 如何检查Backbone.View当前是否在DOM中呈现
- 将View中的项添加到数组中(主干.js)
- 将Backbone.View重新注入DOM,保留事件而不是创建新事件
- 如何为通过ng-view指令或ng-controller指令创建的每个新作用域设置侦听器
- Composer-view.js文件出错
- Ember.js/HHandlebars:使用{{view}}助手渲染的视图不绑定属性
- 如何在asp.net MVC中从View获取值到JavaScript
- 不能从 Backbone.View 的方法调用 Backbone.collection 的方法,其中包含 require
- 如何将 dojox.mobile.View 设置为 100% 的高度
- 在呈现 Ext.view.View 后调用函数
- 如何在Express JS中使用Bliss View Engine而不是Jade
- ng-view 中的脚本在从文件引用时不起作用(JQuery 在角度之前加载)
- 如何在 NativeScript 中获取对 self.view 和 self.view.frame 的引用
- Backbone.View not responding to Backbone.UI
- Ui-view within ui-view
- ng-animate 当 ng-view 通过路由更新时
- React Native:当将TextInput放入View中时,它将消失
- ember.js appending view to just before </body>
- XSRF with AngularJS: DocuSign API Embedded View Client-Side