我正在使用passport-linkedin,我收到此错误: 500 InternalOAuthError:无法获取请求令牌
我正在使用: 节点v0.12.3 表达3.20.3 passport-linkedin@0.1.3 passport-oauth@0.1.15(oauth@0.9.13,passense@0.1.18)
我的代码
app.js
var express = require('express');
var routes = require('./routes');
var http = require('http');
var path = require('path');
var passport = require('passport');
passport.serializeUser(function(user, done) {
done(null, user);
});
passport.deserializeUser(function(obj, done) {
done(null, obj);
});
var app = express();
app.use(passport.initialize());
app.use(passport.session());
// begin linkedin passport -->
var LinkedInStrategy = require('passport-linkedin').Strategy;
var LINKEDIN_API_KEY = "--key--"
var LINKEDIN_SECRET_KEY = "--secret--";
passport.use(new LinkedInStrategy({
consumerKey: LINKEDIN_API_KEY,
consumerSecret: LINKEDIN_SECRET_KEY,
callbackURL: "http://www.mywebsite.com:3000/auth/linkedin/callback"
},
function(token, tokenSecret, profile, done) {
process.nextTick(function () {
console.log("--------------LINKEDIN USER DATA--------------");
console.log("profile.id: "+profile.id);
console.log(profile);
console.log("----------------------------------------");
return done(null, profile);
});
}
));
app.get('/auth/linkedin',
passport.authenticate('linkedin', { scope : ['r_basicprofile', 'r_emailaddress'] } ),
function(req, res){
// The request will be redirected to LinkedIn for authentication, so this
// function will not be called.
});
app.get('/auth/linkedin/callback',
passport.authenticate('linkedin', {
successRedirect : '/home',
failureRedirect: '/login'
})
);
// <-- end linkedin passport
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
提前致谢!