Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/437.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript passport身份验证在回调时做什么?_Javascript_Express_Passport.js_Passport Facebook - Fatal编程技术网

Javascript passport身份验证在回调时做什么?

Javascript passport身份验证在回调时做什么?,javascript,express,passport.js,passport-facebook,Javascript,Express,Passport.js,Passport Facebook,我在我的express项目中使用passport js。下面的第一个路由将在my DB中创建用户,然后返回到第二个回调路由 passport.authenticate('facebook'…)在回调路由器中做什么 如果我在restful API(无会话)中使用它,可以在回调中省略passport.authenticate吗 app.get('/auth/facebook', passport.authenticate('facebook')); app.get('/auth/facebook/

我在我的express项目中使用passport js。下面的第一个路由将在my DB中创建用户,然后返回到第二个回调路由

passport.authenticate('facebook'…)在回调路由器中做什么

如果我在restful API(无会话)中使用它,可以在回调中省略passport.authenticate吗

app.get('/auth/facebook', passport.authenticate('facebook'));

app.get('/auth/facebook/callback',
  passport.authenticate('facebook', { successRedirect: '/',
                                      failureRedirect: '/login' }));
passport.authenticate('facebook'…)在 回叫路由器

这是必需的,以便Facebook在批准后将用户重定向回。如果你删除了它,那么在用户通过Facebook验证后,就不会被重定向到你的站点,或者用户验证就会看到一个错误

如果我在restful API(无会话)中使用它,可以省略 passport.authenticate是否在回调中

app.get('/auth/facebook', passport.authenticate('facebook'));

app.get('/auth/facebook/callback',
  passport.authenticate('facebook', { successRedirect: '/',
                                      failureRedirect: '/login' }));
根据passport.js,如果您希望进行Facebook身份验证,则需要以下路径:

//to send user to facebook
app.get('/auth/facebook', passport.authenticate('facebook'));

//this for facebook to return user back with token, refreshToken, Profile
app.get('/auth/facebook/callback',
  passport.authenticate('facebook', { successRedirect: '/',
                                      failureRedirect: '/login' }));
passport身份验证在回调时做什么

app.get('/auth/facebook', passport.authenticate('facebook'));

app.get('/auth/facebook/callback',
  passport.authenticate('facebook', { successRedirect: '/',
                                      failureRedirect: '/login' }));
Facebook身份验证的验证回调接受
accessToken
refreshttoken
profile
参数。配置文件将包含Facebook提供的用户配置文件信息

js文档是很好的工作原理的来源。还有一些教程向您展示了FB身份验证工作流是如何进行的