gpt4 book ai didi

node.js - ExpressJS 和 Passport-linkedin-oauth2 无法进行身份验证

转载 作者:太空宇宙 更新时间:2023-11-04 02:29:41 25 4
gpt4 key购买 nike

我试图制作一个使用 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、mongoose,并已注册 Linkedin 应用程序来获取 API key 和 key 。我已经检查了 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']
},

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

最佳答案

不确定您是否找到了答案。我遇到了同样的问题,结果发现从 Node 0.10.35 升级到 0.12.2 解决了这个问题。

关于node.js - ExpressJS 和 Passport-linkedin-oauth2 无法进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27922897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com