Я просто пытаюсь поиграть с Docusign API для NodeJS, чтобы получить интеграцию подписывания документов для приложения, которое я создаю.Я думаю, что у меня работает базовое рукопожатие аутентификации.Я создал тестовые маршруты в /docusign
и /docusign/auth
и смог получить токен доступа со следующим кодом.
Я просто хочу получить тестовую ссылку для подписи в своем электронном письме от документа, который я уже загрузил в качестве временного документа, но вызов createEnvelope заканчивает работу с ошибкой:
USER_AUTHENTICATION_FAILED
One or both of Username and Password are invalid. Invalid access token
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);
});
});
});
}
Любая помощь, чтобы указать мне в правильном направлении, будет принята с благодарностью!
Спасибо!