Invalid parameter value for redirect_uri: Missing scheme: / auth / google_auth_code / callback

edit : here is a minimally viable project

I am trying to access and update a token from Google using an authorization code for a server-side stream. I followed the Google Guide here: https://developers.google.com/identity/sign-in/web/server-side-flow .

I use passport and passport-google-authcode .

Following are the routes for the node application:

router.get('/auth/google_auth_code', passport.authenticate('google_authcode', { scope: [ 'https://www.googleapis.com/auth/calendar', 'profile', 'https://www.googleapis.com/auth/userinfo.email' ] }), function () { res.end(); }) router.get('/auth/google_auth_code/callback', passport.authenticate('google_authcode', { failureRedirect: '/error' }), function (req, res) { // do something with req.user res.send('hello'); } ); 

Here is the config passport for this strategy.

 passport.use('google_authcode', new GoogleAuthCodeStrategy({ clientID: 'my client id', clientSecret: 'my secret', callbackURL: '/auth/google_auth_code/callback', // passReqToCallback: true }, function (accessToken, refreshToken, rawResponse, profile, done) { // unable to get here } )); 

When an authentication request is executed, Google responds with the following error:

 { "error" : "invalid_request", "error_description" : "Invalid parameter value for redirect_uri: Missing scheme: /auth/google_auth_code/callback" } 

Here is my credential setting in the Google console:

enter image description here

At this moment I do not know what else to do. I also tried changing the callback url in the passport.use file to an absolute url. I definitely return a valid authorization code (it looks like this: 4/Mb2pcOyhYhziROyFHKH5pnzvUldYbAmMop9SJKbBHXQ ). Let me know if there is any more important information that I can provide.

Thanks,
Sam

change

I noticed that I have URLs ending with a slash above. I fixed this, but I did not update the screenshot.

If I use the full url (e.g. http: // localhost: 8080 // auth / google_auth_code / callback ), I get the following error:

 { "error" : "unauthorized_client" } 

If I use the full url (e.g. http: // localhost: 8080 / auth / google_auth_code / callback ), I get the following error:

 { "error" : "redirect_uri_mismatch" } 
+5
source share
1 answer

This seems to be a passport-google error, as you can see here: https://github.com/jaredhanson/passport-google-oauth/issues/21

What do they offer in these matters: https://github.com/sqrrrl/passport-google-plus

How open source works, you need to either fix it or find another package.

+1
source

Source: https://habr.com/ru/post/1266218/


All Articles