Google身份validationcallback使用Node.js / Passport缺less范围错误

这个错误只发生在Heroku(生产)上,而不是在本地。 我已经尝试了两个:

passport.authenticate('google', { scope: 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/analytics.readonly' }) 

和,

passport.authenticate('google', { scope: ['profile', 'email'] })

范围是数组还是空格分隔的string。

当我转到Google身份validation链接时,范围是在URL中。 在我的现场制作应用程序中生成的内容没有任何区别。

但我仍然得到:

 Error 400 Error: invalid_request Missing required parameter: scope 

我认为您使用Passport Google OAuth,而不仅仅是Passport Google(OpenId)模块?

如果您使用的是OAuth护照,则使用Google进行的身份validation需要额外的范围参数。

作为string传递,您必须通过“openid”作为第一个单词,例如:例如,如果您希望按文件访问用户的Google Drive,

 openid profile email https://www.googleapis.com/auth/drive.file 

来源(S):

https://developers.google.com/identity/protocols/OpenIDConnect#scope-param https://developers.google.com/+/api/oauth#login-scopes

对于错误消息

 Error 400 Error: invalid_request Missing required parameter: scope 

您需要在您的表单中添加范围

 <input type="hidden" name="scope" value="https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo#email https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/tasks https://www-opensocial.googleusercontent.com/api/people https://www.googleapis.com/auth/plus.login" /> 

请参阅linkedin,facebook,twitter和google提供商示例应用程序的spring社交login 。