passport-google-oauth2 icon indicating copy to clipboard operation
passport-google-oauth2 copied to clipboard

Getting a Error 400

Open mango009 opened this issue 7 years ago • 4 comments

I'm getting a error 400 from google

Error: invalid_request Missing required parameter: scope

Looks like the library does not send the scope parameter. Is there anyway to set it?

mango009 avatar Sep 03 '16 23:09 mango009

app.get('/auth/google',
        passport.authenticate('google', { scope: scope }),
            function(req, res) {
                /* do nothing as this request will be redirected to google for authentication */
            }
    );

toadkicker avatar Nov 07 '16 21:11 toadkicker

I'm getting this same error, and I can't find answers anywhere. I'm passing the desired scope to passport.authenticate(), as described by @toadkicker. Here is the line in my app:

api.get('/auth/google', passport.authenticate('google', { scope: auth.google.scope }));

If I change the desired scope, it is reflected on the deny/allow page, so it seems the scope is being sent. The error shows up after Allow is selected.

Any help would be greatly appreciated.

brannonh avatar Mar 13 '17 06:03 brannonh

Figured I should add the return route also.

api.get('/auth/google/return', passport.authenticate('google', { failureRedirect: '/hello/fail', successRedirect: '/hello/succeed' });

Seems this is actually where the error is occurring. If I comment out that line, the request comes back from Google to '/auth/google/return'. So, is Passport redirecting back to the Google error page?

brannonh avatar Mar 16 '17 05:03 brannonh

Forgot to come back here. Seems it was an issue with the way I was setting up my Restify server. I was able to fix this by adding the following code after initializing the server:

api.use(restify.plugins.queryParser({ mapParams: false }));

Once I added that line, I no longer saw the Google error, and the process passed back to my code.

brannonh avatar Jan 08 '18 03:01 brannonh