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.
The values are both matching and I'm printing them out and they are both the same.
Use a backtick to wrap the string value and your life will be a breeze!
clientSecret=`imU86A3oPiZlyOhZybShraP377ers0MvowBaizEQ`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With