[英]Unknown authentication strategy passport
I have setup a MEAN.IO app using the base template and am attempting to add Windows Live and Yahoo passport authentication dependencies. 我已经使用基本模板设置了MEAN.IO应用程序,并尝试添加Windows Live和Yahoo passport身份验证依赖项。
I have npm installed both dependencies and set up the code (see below) just like the other passport schemes like Facebook and Google (which came pre-installed and are working). 我有npm安装了两个依赖项并设置代码(见下文),就像其他护照方案,如Facebook和谷歌(已预先安装并正在运行)。
passport.js: passport.js:
YahooStrategy = require('passport-yahoo-oauth').Strategy,
WindowsLiveStrategy = require('passport-windowslive').Strategy,
GoogleStrategy = require('passport-google-oauth').OAuth2Strategy,
// Use windows live strategy
passport.use(new WindowsLiveStrategy({
clientID: config.strategies.windowslive.clientID,
clientSecret: config.strategies.windowslive.clientSecret,
callbackURL: config.strategies.windowslive.callbackURL
},
function(accessToken, refreshToken, profile, done) {
User.findOne({
'windowslive.id': profile.id
}, function(err, user) {
if (user) {
return done(err, user);
}
user = new User({
name: profile.displayName,
email: profile.emails[0].value,
username: profile.emails[0].value,
provider: 'windowslive',
windowslive: profile._json,
roles: ['authenticated']
});
user.save(function(err) {
if (err) {
console.log(err);
return done(null, false, {message: 'Windows Live login failed, email already used by other login strategy'});
} else {
return done(err, user);
}
});
});
}
));
user routes (server/users/routes.js) 用户路由(server / users / routes.js)
// Setting the windows live oauth routes
app.route('/api/auth/windowslive')
.get(passport.authenticate('windowslive', {
failureRedirect: '/login',
scope: ['wl.signin','wl.basic']
}), users.signin);
app.route('/api/auth/windowslive/callback')
.get(passport.authenticate('windowslive', {
failureRedirect: '/login'
}), users.authCallback);
I keep getting Error: Unknown authentication strategy "windowslive" and Error: Unknown authentication strategy "yahoo" however the facebook and google routes work fine. 我一直得到错误:未知的身份验证策略“windowslive”和错误:未知的身份验证策略“雅虎”但Facebook和谷歌路由工作正常。 Any idea why? 知道为什么吗? Are there any other steps needed to configure new Passport strategies? 是否还需要其他步骤来配置新的Passport策略?
Try adding this to your passport.use statement: 尝试将此添加到passport.use声明中:
passport.use('windowslive', new WindowsLiveStrategy({
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.