Login with Google (Code to Access Token) — Any client to Any server

Photo by marcos mayer on Unsplash

Before starting

Please create an OAuth client on Google Cloud console. You will need the Client ID and the Secret.


The client in our case will be a simple html page. You can make it whatever you want. Just get the code from Google and you are ready.


Our server will run on port 8080, and it will have just one route, as that is all we need for this demonstration. The goal of the server, whatever the stack, is that it receives the code, fetches the access token and then does whatever it likes. For example: you can store the tokens (access, refresh, expiration) for later use. Create a user with the profile info and return the user info back or just return your own JWT token back.




Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store