[英]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.