Ошибка 500 обратного вызова с Passport-WindowsLive

[ФИКСИРОВАННЫЙ]:

в моем коде я пропал

passport.serializeUser(function(user, done) {
  done(null, user);
});

passport.deserializeUser(function(obj, done) {
  done(null, obj);
});

я пишу демонстрационное приложение для доступа к Microsoft на одном диске, когда я http://localhost:3000/auth/mslive, мое приложение перенаправит меня на единый вход с помощью windows-live

однако, функция обратного вызова в "/mslive" и "/mslive/callback" никогда не срабатывает. и я получаю 500 ошибок, когда Windows Live пытается перенаправить обратно в мое приложение. любая идея?

Remote Address:127.0.0.1:3000
Request URL:http://anotherdemoapp.localtest.me:3000/auth/mslive/callback?code=d3f9d642-b013-af4e-e4d0-0cb828554ca5
Request Method:GET
Status Code:500 Internal Server Error

app.js

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

var routes = require('./routes/index');
var authRoutes = require("./routes/auth");

var app = express();

//// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);
app.use("/auth", authRoutes);

auth.js

var express = require('express');
var path = require("path");
var passport = require("passport");
var passportMSLive = require("passport-windowslive");
var app = express();

app.use(passport.initialize());

passport.use(new passportMSLive.Strategy({
        clientID: process.env.MSLiveClientID,
        clientSecret: process.env.MSLiveClientSecret,
        callbackURL: "http://anotherdemoapp.localtest.me:3000/auth/mslive/callback"
    },
    function (accessToken, refreshToken, profile, done) {
       // this callback function will be invoked after successfully login
       return done(null, profile);  
    }
));

// call back
app.get(
    "/mslive",
    passport.authenticate("windowslive", {
        scope: ["wl.offline_access", "wl.contacts_skydrive", "wl.skydrive", "wl.skydrive_update", "wl.signin"]
    }),
    function (req, res) {
        // never enter here
        res.send("mslive login");
    }
);

app.get(
    "/mslive/callback",
    passport.authenticate("windowslive", {
        failureRedirect: '/mslive/fail'
    }),
    function (req, res) {
        // never enter here
        res.send("mslive callback");
    }
);

app.get("/mslive/fail", function (req, res) {
    // never enter here
    res.send("login failed");
});

module.exports = app;

0 ответов

Другие вопросы по тегам