Test the app here: https://oauth.arcade.build
Read the blog for implementation details Google OAuth 2.0 Flow in Golang and React.js
- Get your Client ID and secret keys from google cloud https://console.cloud.google.com/auth/clients
- Create
.env
file and update the env variables from.env.example
file- for local run
HTTP_COOKIE_HTTPONLY=false HTTP_COOKIE_SECURE=false
- for local run
- Use docker for running the app, all the services are listed in
docker-compose.yml
~> docker compose build
~> docker compose up
- OAuth Flow
- User requests for login from the client app
- The client app hits login endpoint on the backend
- The backend server generates the unqiue url of auth provider consent page and redirects the request
- The consent page opens directly to the user requesting for granting permission
- The user gives access to the permission, then auth provider calls the callback url of the backend server
- The backend server then generates the access and refresh tokens and sets them in http only cookies
- The backend server then redirects to the success page of the client app
- Access & Refresh token Flow
- Backend sets access and refresh token to http only cookie
- Client calls protected routes using the access token
- If the access token expires, the client then calls
/refresh-token
API using the refresh token from cookies - Backend then issues new access token and sets it in the cookie
- Golang
- React.js
- MySQL
- Docker
- Google OAuth