An example implementation of Google OAuth2/OIDC authentication for Axum. This was inspired by example implimentation for discord.
I wrote a blog post about this repository.
blog-20241206-02.mp4
- Obtain Client ID and Client Secret from Google https://console.cloud.google.com/apis/credentials
- Add "https://localhost:3443/auth/authorized" to "Authorized redirect URIs"
- You can replace
localhost:3443
with your host's FQDN - You can also use ngrok hostname
- You can replace
- Edit .env file
CLIENT_ID=$client_id
CLIENT_SECRET=$client_secret
ORIGIN='https://localhost:3443'
#(Optional: Run ngrok by `ngrok http 3000`)
#ORIGIN="https://xxxxx.ngrok-free.app"
- Start the application
cargo run