Missing scope error on Google authentication callback using Node.js/Passport

heroku, javascript, node.js, passport.js

Solution

I take it you are using the Passport Google OAuth, not just the Passport Google (OpenId) module?

If you are using the OAuth passport, the authentication with Google requires an extra scope parameter.

Pass as a string, you must pass 'openid' as the 1st word, eg: For example, if you wanted per-file access to a user’s Google Drive,

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

Source(s):

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

Problem

This error occurs on Heroku (production) only, not on local. I have tried both: ``` passport.authenticate('google', { scope: 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/analytics.readonly' }) ``` And, `passport.authenticate('google', { scope: ['profile', 'email'] })` Whether the scope is an array, or a space-delimited string. When I go to the Google authentication link, scope IS in the URL. There is no difference in the one generated in my live production app. But I still get: ``` Error 400 Error: invalid_request Missing required parameter: scope ```

Original source

Related problems