I've got a simple client app using react-google-login with this settings:
<GoogleLogin
clientId={config.CLIENT_ID}
scope={config.SCOPES.join(' ')}
buttonText="Login With Google"
onSuccess={response => onSignIn('google', response)}
onFailure={this.failure.bind(this)}
accessType="offline"
responseType="code"
/>
It retrieves the code successfully and sends it to the backend server which is written with NodeJS.
The server-side code looks like this:
const { google } = require('googleapis');
const config = global.config;
const oauth2Client = new google.auth.OAuth2({
clientId: config.google.CLIENT_ID,
clientSecret: config.google.CLIENT_SECRET,
});
// code omitted for the sake of simplicity
var authCode = req.body.authCode; // the provided code by google
const { tokens } = await oauth2Client.getToken(authCode);
return tokens;
When I run the code, it throws the error:
{ error: 'invalid_request',
error_description: 'Missing parameter: redirect_uri' } },
code: '400' }
and if I add redirectUrl to Developer Console, client app and server-side app, I'll get redirect_uri_mismatch
error.
I'm kind of stuck here and couldn't find anything useful on the web.
Any workaround would be appreciated.