簡體   English   中英

DocuSign API身份驗證問題

[英]DocuSign API Authentication Problems

我只是嘗試使用Docusign API for 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);
        });
    });
});

}

任何幫助我指出正確方向的幫助將不勝感激!

謝謝!

代替

    var envelopesApi = new docusign.EnvelopesApi();

嘗試

    var envelopesApi = new docusign.EnvelopesApi(apiClient);

另外,有關帶有DocuSign和授權代碼授予的Node的工作示例,請查看此示例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM