Search code examples
node.jsexpresspassport.jspassport-facebook

ReferenceError: [client_secret] is not defined. nodejs passport-fb


I was trying to understand how work FB login API and found a tutorial but I'm stuck. I don't know why this error:

C:\Users\DELAO\Desktop\lol\app.js:12
clientSecret: [App_Secret],
            ^

ReferenceError: fbbb55cd0c1c9886a8ec95d283863f is not defined
at Object.<anonymous> (C:\Users\DELAO\Desktop\lol\app.js:12:17)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

This is the code that I found:

const express = require("express");
const passport = require("passport");
const FacebookStrategy = require("passport-facebook"); 
const app = express();

app.use(express.static("public"));
app.set("view engine", "ejs");


passport.use(new FacebookStrategy({
clientID: [APP_id],
clientSecret: [APP_secret],
callbackURL: "http://localhost:3000/auth/facebook/callback"
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate(accessToken, function(err, user) {
if (err) { return done(err); }
done(null, user);
});
}
));

I already created my app in FB Please help! I'm so noob


Solution

  • You have to add ' to your clientSecret.

    clientSecret: 'fbbb55cd0c1c9886a8ec95d283863f'
    

    With your current situation, the node.js js engine thinks it is a variable, not a string value