【发布时间】:2019-10-28 14:51:51
【问题描述】:
我已经定义了一个路由“auth/google”,它负责使用 google 登录应用程序。出现登录同意屏幕(不需要 passport.initialize())。我已经将回调 Url 定义为 'auth/google/callback ' 也。为什么我收到错误中间件(passport.initialize())未使用
// using pasport.authenticate for authenicate the request (no error for not using passport.initialize())
app.get('/auth/google' , passport.authenticate('google',{
scope: ['profile','email']
})
// got error after writing below code
app.get('/auth/google/callback' , passport.authenticate('google'),(req,res)=>{
res.json({"a":97});
});
【问题讨论】:
-
你能发布你的中间件进口订单吗?
-
我有一个路由文件“authroutes.js”,它有两个路由并导出了一个函数以在 index.js(入口文件)中要求它,并且我在 passport.js 文件中配置了谷歌策略。在条目文件中,我评论了护照的初始化,因此我收到错误
-
@VaibhavKumarGoyal passport.serializeuser() 在没有 passport.initialize() 的情况下不会调用。为什么会这样?
-
查看发布的答案
标签: express authentication oauth-2.0 passport.js google-oauth