当我通过锚链接访问 / auth / provider / 时,会打开一个空白页但是如果我访问的话, passport.authenticate('provider'))不会被调用 / auth / provider / 直接 passport.authenticate('provider'))被调用。
var express = require('express');
var passport = require('passport');
var OAuth2Strategy = require('passport-oauth').OAuth2Strategy;
var routes = require('./routes');
var app = module.exports = express();
passport.use('provider', new OAuth2Strategy({
authorizationURL: 'https://example.com/oauth/authorize',
tokenURL: 'https://example.com/oauth/token',
clientID: "777myclientid",
clientSecret: "555dontstealmyclientsecret",
callbackURL: 'http://localhost:5000/callback'
},
function(accessToken, refreshToken, profile, done) {
console.log(profile);
}
));
app.configure(function(){
app.engine('.html', require('ejs').renderFile)
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(passport.initialize());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.get('/', routes.index);
app.get('/partials/:name', routes.partials);
app.get('/auth/provider', passport.authenticate('provider'));