Monday, 13 March 2017

NodeJS dotenv - Not reading string value properly

I'm trying to us dotenv (https://github.com/motdotla/dotenv) in nodeJS to store the client secret value for an oauth server I'm using.

My .env file looks like the following:

clientSecret=imU86A3oPiZlyOhZybShraP377ers0MvowBaizEQ

Within the NodeJS file, I have the following:

passport.use(new PasswordGrantStrategy({
    tokenURL: 'WEBSITE_ADDRESS',
    clientID: "2",
    clientSecret: process.env.clientSecret,
    grantType: "password",

},

The problem is that I get a Token Error but, if I change it the following:

passport.use(new PasswordGrantStrategy({
    tokenURL: 'WEBSITE_ADDRESS',
    clientID: "2",
    clientSecret: "imU86A3oPiZlyOhZybShraP377ers0MvowBaizEQ",
    grantType: "password",

},

This then works perfectly fine. I don't understand what the problem could be and I've tried to cast it as a string but no such luck.



via Phorce

No comments:

Post a Comment