I am integrating a google identity authentication flow in my web application.
I have an internal user model so when the user authenticate via google i would like to reconicilate the email i received with my internal user model (and insert a new internal user if the email cannot be found).
I created a route that is taking a google oauth token as input, validate it and returns an internal jwt authenticated token if everything went right.
What is the best flow i should implement ? I am considering two options :
-
Front calls the google authentication flow, in the google console i set up the redirect uri so a call will be made to my backend. I return the authentication token to the front by storing it in a cookie a doing a redirect to the frontend
-
Front calls the google authentication flow. The google authentication flow redirects to the front end. The front end retrieves the google token calls my backend with, the internal jwt token is returned as api output (no need for cookie or redirect).
What is the best practice ? Am i missing another way ?
Thanks
I read the documentation https://developers.google.com/identity/gsi/web/guides/verify-google-id-token?hl=en which is not clear about this use case
Rémi Pradal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.