繁体   English   中英

ExpressJS和通行证-linkedin-oauth2无法验证

[英]ExpressJS and passport-linkedin-oauth2 cannot authenticate

我试图给出一个使用passport-linkedin-oauth2的简单示例,然后遇到了这个问题:

这是服务器端的日志:

{ [CastError: Cast to number failed for value "XXXXXX" at path "oauthID"]
message: 'Cast to number failed for value "XXXXXX" at path "oauthID"',
name: 'CastError',
type: 'number',
value: 'XXXXXX',
path: 'oauthID' }

这是客户端的错误日志:

TokenError: missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : appId or redirect uri does not match authorization code or authorization code expired
at Strategy.OAuth2Strategy.parseErrorResponse (/Users/percevio/projects/web-learning/passportjs/open-auth/node_modules/passport-linkedin-oauth2/node_modules/passport-oauth2/lib/strategy.js:298:12)
at Strategy.OAuth2Strategy._createOAuthError (/Users/percevio/projects/web-learning/passportjs/open-auth/node_modules/passport-linkedin-oauth2/node_modules/passport-oauth2/lib/strategy.js:345:16)
at /Users/percevio/projects/web-learning/passportjs/open-auth/node_modules/passport-linkedin-oauth2/node_modules/passport-oauth2/lib/strategy.js:171:43
at /Users/percevio/projects/web-learning/passportjs/open-auth/node_modules/passport-linkedin-oauth2/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:177:18
at passBackControl (/Users/percevio/projects/web-learning/passportjs/open-auth/node_modules/passport-linkedin-oauth2/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:124:9)
at IncomingMessage.<anonymous> (/Users/percevio/projects/web-learning/passportjs/open-auth/node_modules/passport-linkedin-oauth2/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:143:7)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:442:13)

我正在使用ExpressJS,猫鼬,并且已经注册了Linkedin应用程序以获取API密钥和秘密密钥。 而且我已经检查了OAuth 2.0重定向URL。

用户架构:

//Create a user model
var User = mongoose.model('User',{
    oauthID:Number,
    name:String,
    created:Date
});

这就是我配置linkedStrategy的方式:

passport.use(new LinkedInStrategy({
    clientID:config.linkedin_oauth2.clientID,
    clientSecret:config.linkedin_oauth2.clientSecret,
    callbackURL:'http://localhost:3000/auth/linkedin/callback',
    state:true,
    scope: ['r_basicprofile']
},

有什么建议吗? 非常感谢你!

不知道您是否找到答案。 我遇到了同样的问题,事实证明,从节点0.10.35升级到0.12.2可以为我解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM