【发布时间】:2022-02-11 08:32:48
【问题描述】:
我正在使用 Passport.js 通过 GoogleStrategy 将我的 Node 应用程序连接到 Google+ API。 我将 auth/api 路由从我的前端 (localhost:3000) 调用到我的服务器 (localhost:5150)。 我的代码成功到达路由并调用了 passport.authenticate("google", { scope: ["email"] }) 方法,但没有执行任何操作。我的前端只是无休止地等待 Google 回调,但它永远不会到来。
为什么会这样?
我的代码:
export const authenticateUsingGoogle = (req, res) => {
console.log(`authenticating using google`);
passport.authenticate("google", { scope: ["email", "openid", "profile "] });
console.log(`authenticated using google`);
};
我在 Stackoverflow 上看到过两个类似的问题,但他们没有答案:
【问题讨论】:
标签: node.js express google-api passport.js