Search code examples
javascriptnode.jsenvironment-variablesdocusignapidotenv

.env process.env isn't working with DocuSign docusignAPI using node.js example


I'm using the example from docusign at https://github.com/docusign/qs-02-node-send-envelope , and have configured the index.js file the ACCESS_TOKEN, ACCOUNT_ID, USER_FULLNAME and USER_EMAIL it worked fine. But when I configure the .env file it doesn't work.

I did install $ npm install and $ npm install dotenv.

ACCESS_TOKEN=eyJ0eXMtNjg5ODEyMjAzMzETtl0--w
ACCOUNT_ID=123456
USER_FULLNAME="Larry Smith"
[email protected]

this is the localhost answer

API problem

Status code 401

Error message:

{
    "errorCode": "AUTHORIZATION_INVALID_TOKEN",
    "message": "The access token provided is expired, revoked or malformed."
}

with the console.log(accessToken) it replies ACCESS_TOKENinstead of eyJ0eXMtNjg5ODEyMjAzMzETtl0--w

Need help to set up process.env with docusign or docusignapi.


Solution

  • From dotenv docs:

    As early as possible in your application, require and configure dotenv.

    require('dotenv').config()
    

    You may turn on logging to help debug why certain keys or values are not being set as you expect.

    require('dotenv').config({ debug: process.env.DEBUG })