我正在使用passport-linkedin,我收到了这个错误。
InternalOAuthError: failed to obtain request token
at /Users/davey/code/node/appify-frontend/node_modules/passport-linkedin/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:196:36
at /Users/davey/code/node/appify-frontend/node_modules/passport-linkedin/lib/passport-linkedin/strategy.js:80:19
at passBackControl (/Users/davey/code/node/appify-frontend/node_modules/passport-linkedin/node_modules/passport-oauth/node_modules/oauth/lib/oauth.js:397:13)
at IncomingMessage.<anonymous> (/Users/davey/code/node/appify-frontend/node_modules/passport-linkedin/node_modules/passport-oauth/node_modules/oauth/lib/oauth.js:409:9)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
GET /oauth/linkedin 500 1074ms - 786b
以下是我的设置
exports.setup = function (config) {
var passport = require('passport');
var LinkedinStrategy = require('passport-linkedin').Strategy;
passport.use(new LinkedinStrategy({
consumerKey: config.linkedin.clientID,
consumerSecret: config.linkedin.clientSecret,
callbackURL: config.linkedin.callbackURL
},
function(token, tokenSecret, profile, done) {
console.log(token, tokenSecret, profile);
return done(null, true);
}
));
};
我的路由设置如下
router
.get('/',
function(req, res, next) {
console.log("[OAuth2:redirect:query]:", JSON.stringify(req.query));
console.log("[OAuth2:redirect:body]:", JSON.stringify(req.body));
next();
},
passport.authenticate('linkedin', {
failureRedirect: '/settings/connected-accounts',
session: false
}))
.get('/callback', passport.authenticate('linkedin', {
failureRedirect: '/settings/connected-accounts',
session: false
}), function (req, res){
res.redirect('/settings/connected-accounts');
});
在同一个应用程序中,我设置了twitter和facebook oauth,两者都运行良好。我不知道是什么导致了这个错误,并尝试了所有的东西。
在我的linkedin开发者帐户中,我已按原样配置了所有内容。
授权重定向网址:
http://testdomain.ngrok.io/oauth/linkedin/callback
默认“接受”重定向网址:
http://testdomain.ngrok.io/settings/connected-accounts
我首先使用在端口9000上运行的localhost url,但是当失败时,我将我的应用程序本地运行到了一个实时URL,但我仍然遇到了同样的错误。 任何帮助表示赞赏。感谢
答案 0 :(得分:1)
InternalOAuthError
与passport-oauth1(https://github.com/jaredhanson/passport-linkedin/blob/master/lib/strategy.js)有关,但您根据路由设置使用OAuth2。因此,请尝试切换到passport-linkedin-oauth2