[英]Social authentication using passports js and angular 2
My angular 2 app runs in localhost:4200 and node api server runs in 8080 port. 我的angular 2应用程序在localhost:4200中运行,而node api服务器在8080端口中运行。 How can I pass the user data once user has successfully completed the single sign on request to the client app.
一旦用户成功完成对客户端应用程序的单点登录请求,我该如何传递用户数据。
Passport JS code: Passport JS代码:
router.get('/auth/facebook', passport.authenticate('facebook', { scope: 'email' }));
router.get('/auth/facebook/callback', passport.authenticate('facebook', {
successRedirect: 'http://localhost:4200/',
failureRedirect: 'http://localhost:4200/',
}));
Angular 2 code: Angular 2代码:
facebooklogin()
var newWindow = window.open(`http://localhost:8080/auth/facebook`,'name', 'height=585, width=770');
if (window.focus) {
newWindow.focus();
}
/* how can I get the passport session data here */
}
您可以在成功案例中进行重定向,并将信息添加为查询参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.