0
votes

I've followed the steps google has provided for integrating sign-in, provided here: https://developers.google.com/identity/sign-in/web/sign-in within my MERN stack application.

The button that I've created, correctly redirects to the google authentication site. However, after the user is authenticated with google, the google authentication site is closed and no redirection occurs. I'm expecting to be redirected to http://localhost:3000/profile after a user is authenticated.

I've set Authorized JavaScript origins to http://localhost:3000 and Authorized redirect URIs to http://localhost:3000/profile.

How can I update my code to have this redirect as expected?

1

1 Answers

0
votes

If your code for authorizing with google lives in your server file, wich is running on a diffrent port than port 3000 you should set your JavaScript origins to the port of the server. Not the port of your react app.

Example for a server on port 4000

This article covers the whole proces of using oAuth in the MERN stack step by step: https://medium.com/@maartendebaecke2/mern-stack-implementing-sign-in-with-google-made-easy-9bfdfe00d21c