node.js - 引用错误: [client_secret] is not defined. NodeJS Passport-fb

标签 node.js express passport.js passport-facebook

我试图了解 FB 登录 API 的工作原理并找到了一个教程,但我陷入困境。我不知道为什么会出现这个错误:

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)

这是我找到的代码:

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);
});
}
));

我已经在 FB 中创建了我的应用程序请帮忙!我真是菜鸟

最佳答案

您必须将 ' 添加到您的 clientSecret。

clientSecret: 'fbbb55cd0c1c9886a8ec95d283863f'

按照你目前的情况,node.js js引擎认为它是一个变量,而不是字符串值

关于node.js - 引用错误: [client_secret] is not defined. NodeJS Passport-fb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54005846/

相关文章:

node.js - 如何在 nodejs 应用程序中使用 kubernetes secrets?

Node.js,如何避免事件命名空间冲突?

node.js - res.send 发送后无法设置 header

angularjs - 类型错误 : Dbschema(Mongoose Schema) is not a function

node.js - Passport : Authenticating the whole app instead of some requests

javascript - 如何使用 Node - Express - Passport 使用 "/"进行登录和登录主页?

node.js - 无法使用 Node 示例从heroku local连接到heroku postgres

javascript - 从 nodejs 以 html 格式共享文件

node.js - 如何使断开连接事件仅在用户从帐户注销时触发(node.js + Express socket.io)

node.js - 我正在尝试使用 Express 和 Passport 创建一个 nodejs 登录系统,但出现错误