Google OAuth: redirect_uri_mismatch
The Problem: The URL that SpaceDF sends to Google does not exactly match the URL you allowed in the Google Cloud Console.
1. The Golden Rule
To fix this, you must understand how SpaceDF constructs the URL.
| Location | Config Name | Value Format | Example |
|---|---|---|---|
| Your Server (.env) | GOOGLE_CALLBACK_URL | Base Domain Only | https://your-domain.com |
| Google Console | Authorized Redirect URI | Full Path | https://your-domain.com/auth/google/callback |
โ ๏ธ Crucial Difference
SpaceDF automatically appends /auth/google/callback to your .env value.
๐ Do NOT add the path in your .env file.
๐ DO add the path in Google Console.
2. Step-by-Step Fix
Check your .env file
Open your .env file and ensure GOOGLE_CALLBACK_URL contains only the protocol and domain (and port if local).
# โ
CORRECT (Base URL only)
GOOGLE_CALLBACK_URL=[https://your-domain.com](https://your-domain.com)
# โ INCORRECT (Do not add the path here)
GOOGLE_CALLBACK_URL=[https://your-domain.com/auth/google/callback](https://your-domain.com/auth/google/callback)Update Google Cloud Console
Please follow Google Oauth Guide in the Advanced Setup section
Restart Services
Environment variables are only loaded when the container starts.
docker compose down
docker compose up -d3. Common Mistakes Checklist
๐ Troubleshooting Checklist
- Protocol: Did you write
httpin.envbuthttpsin Google Console? (Must match). - Trailing Slash: Did you put
https://site.com/in.env? (Remove the trailing slash). - Port: Are you using port
80or443but explicitely wrote:3000? - Environment: Did you configure the Production URL but are trying to log in from Localhost? (You need both entries in Google Console).
Last updated on