Gary
Gary

Reputation: 851

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

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

Upvotes: 17

Views: 5214

Answers (2)

Sunil Kumar
Sunil Kumar

Reputation: 5647

For error message

Error 400
Error: invalid_request
Missing required parameter: scope

You need to add scopes in your form

<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" />

Please refer spring social login with linkedin,facebook,twitter and google providers example application.

Upvotes: -1

Sharry
Sharry

Reputation: 150

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

Upvotes: 7

Related Questions