Node.js DocuSign API身份验证问题
我只是在尝试为NodeJS使用docusignapi,以便为我正在构建的应用程序实现文档签名集成。我想我已经有了基本的认证握手功能。我在Node.js DocuSign API身份验证问题,node.js,authentication,docusignapi,Node.js,Authentication,Docusignapi,我只是在尝试为NodeJS使用docusignapi,以便为我正在构建的应用程序实现文档签名集成。我想我已经有了基本的认证握手功能。我在/docusign和/docusign/auth创建了测试路由,并且我能够使用以下代码获得访问令牌 我只想在我的电子邮件中获得一个测试签名链接,该链接来自一个我已经作为临时文件上传的文档,但是createEnvelope调用以捕获错误而结束: 用户\u身份验证\u失败 用户名和密码中的一个或两个无效。无效的访问令牌 provide.generateAccessT
/docusign
和/docusign/auth
创建了测试路由,并且我能够使用以下代码获得访问令牌
我只想在我的电子邮件中获得一个测试签名链接,该链接来自一个我已经作为临时文件上传的文档,但是createEnvelope调用以捕获错误而结束:
用户\u身份验证\u失败
用户名和密码中的一个或两个无效。无效的访问令牌
provide.generateAccessToken = (req, res, next) => {
apiClient.generateAccessToken(integratorKey, clientSecret, req.query.code, function (err, oAuthToken) {
console.log(oAuthToken);
apiClient.setBasePath(basePath);
//IMPORTANT: In order to access the other api families, you will need to add this auth header to your apiClient.
apiClient.addDefaultHeader('Authorization', 'Bearer ' + oAuthToken.accessToken);
var envelopesApi = new docusign.EnvelopesApi();
envelopesApi.apiClient.addDefaultHeader('Authorization', 'Bearer ' + oAuthToken.accessToken);
apiClient.getUserInfo(oAuthToken.accessToken, function (err, userInfo) {
console.log("UserInfo: " + userInfo);
// parse first account's baseUrl
// below code required for production, no effect in demo (same
// domain)
//apiClient.setBasePath(userInfo.accounts[0].baseUri + "/restapi");
// create a new envelope object that we will manage the signature request through
var envDef = new docusign.EnvelopeDefinition();
envDef.emailSubject = 'Rental Application';
envDef.templateId = '66c8c9cf-xxx-xxxx-xxxx-xxxxxxxx';
// create a template role with a valid templateId and roleName and assign signer info
var tRole = new docusign.TemplateRole();
tRole.roleName = 'Applicant';
tRole.name = 'test';
tRole.email = 'myemailtest@gmail.com';
// create a list of template roles and add our newly created role
var templateRolesList = [];
templateRolesList.push(tRole);
// assign template role(s) to the envelope
envDef.templateRoles = templateRolesList;
// send the envelope by setting |status| to 'sent'. To save as a draft set to 'created'
envDef.status = 'sent';
// use the |accountId| we retrieved through the Login API to create the Envelope
var accountId = userInfo.sub;
// instantiate a new EnvelopesApi object
// call the createEnvelope() API
envelopesApi.createEnvelope(accountId, {'envelopeDefinition': envDef}, function (err, envelopeSummary, response) {
if (err) {
return next(err);
}
console.log('EnvelopeSummary: ' + JSON.stringify(envelopeSummary));
return JSON.stringify(envelopeSummary);
});
});
});
}
如果您能为我指明正确的方向,我们将不胜感激
谢谢 而不是
var envelopesApi = new docusign.EnvelopesApi();
试一试
此外,对于具有DocuSign和授权代码授权的节点的工作示例,请查看此最终就是它。实际上,我已经手动设置了baseUri和标头:
envelopesApi.apiClient.setBasePath(userInfo.accounts[0].baseUri+“/restapi”)代码>envelopesApi.apiClient.addDefaultHeader('Authorization'、'Bear'+oAuthToken.accessToken)代码>在意识到有一个setApiClient
函数之前。你的回答更清楚,所以我会接受。谢谢
var envelopesApi = new docusign.EnvelopesApi(apiClient);