Search code examples
docusignapienvelope

USER_AUTHENTICATION_FAILED Creating Envelope


Currently I'm working with a Node.js integration for DocuSign (https://www.npmjs.com/package/docusign-esign), I made all the test with the sandbox account and worked perfectly, right now I'm trying to use a production account, the login process is fine but when I'm going to create the envelope I get a USER_AUTHENTICATION_FAILED error (even if the first login went without errors). I would like to know if someone has experienced same thing or has an idea of how can I fix this.

This is the code that I took from the docusign-esign to create the envelope:

var loginAccount = new docusign.LoginAccount();
loginAccount = loginAccounts[0];
var accountId = loginAccount.accountId;   

var envelopesApi = new docusign.EnvelopesApi();

envelopesApi.createEnvelope(accountId,  envDef, null, function (error, envelopeSummary, response)

The account Id is the same retrieved after the login process.


Solution

  • One possible cause could be that your DocuSign account is hosted on na2.docusign.net, na3.docusign.net or eu.docusign.net, while your code uses the default www.docusign.com as a base URL.

    The login call will pass even if you use www, however all the subsequent API calls will fail if you are not hitting the exact base URL that corresponds to your production account. You should have received this information as part of the DocuSign Go-Live process (formerly known as API Certification). You can always get the base URL from the login call response.

    For Node, here how to get the correct base URL from the login call and set it up to the API Client (lines in bold are likely what is missing in your code):

    authApi.login(loginOps, function (err, loginInfo, response) {
      if (err) {
        return next(err);
      }
      if (loginInfo) {
        // list of user account(s)
        // note that a given user may be a member of multiple accounts
        var loginAccounts = loginInfo.getLoginAccounts();
        console.log('LoginInformation: ' + JSON.stringify(loginAccounts));
        var loginAccount = loginAccounts[0];
        var accountId = loginAccount.accountId;
    

    var baseUrl = loginAccount.baseUrl;

    var accountDomain = baseUrl.split("/v2");

    apiClient.setBasePath(accountDomain[0]);

    docusign.Configuration.default.setDefaultApiClient(apiClient);

    next(null, loginAccount);
      }
    });