Post Go Live issue with Docusign using node.js
Asked Answered
B

2

8

Here is my issue:

  • We integrated docusign in our application, server side with nodejs using this tutorial https://github.com/docusign/docusign-node-client ("OAuth JSON Web Token (JWT) Grant" section)
  • We have done the "Go Live Process": our application is registered in our production account
  • We have replaced the test config to the production config.
  • When we try to create an envelope, we get the following error: PARTNER_AUTHENTICATION_FAILED: The specified Integrator Key was not found or is disabled. Invalid account specified for user

What am I doing wrong ?

async function docusignInit() {
    var options;
    var env = [40077,50077].indexOf(config.main.port) != -1 ? 'test' :'prod';
    if (env == "test") {
        options = {
            basePath: restApi.BasePath.DEMO,
            oAuthBasePath: oAuth.BasePath.DEMO
        }
    } else {
        options = {
            oAuthBasePath: "account.docusign.com",
           // We called https://account.docusign.com/oauth/userinfo to found the uri
            basePath:"https://eu.docusign.net/restapi/"
        }
    }
    // in production, We must do
    // var apiClient = new docusign.ApiClient(options.basePath);
    // Otherwise, we get "Error: getaddrinfo ENOTFOUND undefined undefined:443"
    var apiClient = new docusign.ApiClient(options.basePath);
    var privateKeyFile = fs.readFileSync(`./server/docusign/keys/${env}/private.PEM`);
    var res = await apiClient.requestJWTUserToken(config.docusign.integratorKey, config.docusign.userName, [oAuth.Scope.IMPERSONATION, oAuth.Scope.SIGNATURE], privateKeyFile, 3600)
    var token = res.body.access_token;
    apiClient.addDefaultHeader('Authorization', 'Bearer ' + token);
    docusign.Configuration.default.setDefaultApiClient(apiClient);
    await sendDocusign({
        userId: 1,
        firstName: 'foor',
        lastName: 'bar',
        email:'foo@bar;'
    })
}


async function sendDocusign(role) {

    var envDef = new docusign.EnvelopeDefinition();
    envDef.emailSubject = 'Please signe this';
    envDef.templateId = config.docusign.templateId;

    var role = new docusign.TemplateRole();
    role.roleName = "roleName";
    role.clientUserId = role.userId;
    role.name = role.firstName + " " + role.lastName;
    role.email = role.email;

    envDef.allowReassign = false;
    envDef.templateRoles = [role];
    envDef.status = 'sent';

    var envelopesApi = new docusign.EnvelopesApi();
    return await envelopesApi.createEnvelope(config.docusign.userAccountId, {
        'envelopeDefinition': envDef
    })
}
Bloodstock answered 26/4, 2019 at 14:21 Comment(0)
P
1

As you are able to generate AccesToken properly in PROD with PROD RSA KeyPair, so please check the endpoint which you using to make API calls to create an envelope. In demo it is always demo.docusign.net but in PROD it will be a different value depending on where you PROD account exists in the DocuSign data center. For instance if your PROD account is in NA1, then hostname will be will be www.docusign.net; if it is NA2 then hostname will be na2.docusign.net etc.

So it is recommended to make a /userinfo API call with the Access token to know the baseURI to make calls related to envelope. To get the base URI, call the /oauth/userinfo endpoint, supplying your application’s access token as a header.

Documentation related to /userinfo API call is available here. Once you know you BaseURI then append this baseURI with envelopes related endpoint like below:

{base_uri} + "/restapi/v2.1/accounts/" + {account_id}
Process answered 24/7, 2019 at 16:56 Comment(0)
G
0

considering your error seems that you're missing the integratorKey or you're writing it in the wrontg way. According to that LINK is possible that you miss the brackets inside the intregrator key?

The integrator key must be placed in front of the user ID that is in the Username node of the UsernameToken. The integrator key must be wrapped with brackets, “[ and ]”.

An example of the api in the above documentation:

<soap:Header>
   <wsa:Action>http://www.docusign.net/API/3.0/GetRecipientEsignList</wsa:Action>
   <wsa:MessageID>uuid:3f9d7626-c088-43b4-b579-2bd5e8026b17</wsa:MessageID>
   <wsa:ReplyTo>
      <wsa:Address>http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:Address>
   </wsa:ReplyTo>
   <wsa:To>http://demo.docusign.net/api/3.0/api.asmx</wsa:To>
   <wsse:Security soap:mustUnderstand="1">
      <wsu:Timestamp wsu:Id="Timestamp-8838aa24-9759-4f85-8bf2-26539e14f750">
         <wsu:Created>2006-04-14T14:29:23Z</wsu:Created>
         <wsu:Expires>2006-04-14T14:34:23Z</wsu:Expires>
      </wsu:Timestamp>
      <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-7c7b695e-cef7-463b-b05a-9e133ea43c41">
         <wsse:Username>[Integrator Key Here]2988541c-4ec7-4245-b520-f2d324062ca3</wsse:Username>
         <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
         <wsse:Nonce>SjlScsL5q3cC1CDWrcMx3A==</wsse:Nonce>
         <wsu:Created>2006-04-14T14:29:23Z</wsu:Created>
      </wsse:UsernameToken>
   </wsse:Security>
</soap:Header>
Gammy answered 6/5, 2019 at 9:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.