首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未知身份认证策略护照

未知身份认证策略护照
EN

Stack Overflow用户
提问于 2015-06-24 15:00:55
回答 1查看 4.2K关注 0票数 4

我已经使用基本模板设置了一个MEAN.IO应用程序,并试图添加Windows和雅虎护照身份验证依赖项。

我已经安装了npm的两个依赖项,并设置了代码(见下文),就像其他护照计划,如Facebook和Google (这是预装的,而且正在运行)。

passport.js:

代码语言:javascript
复制
YahooStrategy = require('passport-yahoo-oauth').Strategy,
WindowsLiveStrategy = require('passport-windowslive').Strategy,
GoogleStrategy = require('passport-google-oauth').OAuth2Strategy,
代码语言:javascript
复制
// 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 .)

代码语言:javascript
复制
// 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);

我一直收到错误:未知身份验证策略"windowslive“和错误:未知身份验证策略"yahoo”,但是facebook和google路由运行良好。知道为什么吗?是否还需要其他步骤来配置新的护照策略?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-17 04:05:52

尝试将其添加到您的passport.use语句中:

代码语言:javascript
复制
passport.use('windowslive', new WindowsLiveStrategy({
...
票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31030067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档