Skip to content

Conversation

@bokelley
Copy link
Contributor

Problem

Getting redirect_uri_mismatch error from Google OAuth because:

  • Google OAuth credentials expect: https://sales-agent.scope3.com/admin/auth/google/callback
  • Flask generates: https://sales-agent.scope3.com/auth/google/callback (missing /admin)

The issue is that nginx routes all admin UI traffic through /admin/* but Flask doesn't know about this prefix.

Solution

Auto-detect and add /admin prefix to the OAuth redirect URI when GOOGLE_OAUTH_REDIRECT_URI environment variable is not set.

Changes

  • Check if generated URL already has /admin prefix
  • If not, add it: /auth/google/callback/admin/auth/google/callback
  • Add logging to show the actual redirect URI being used
  • Still respects GOOGLE_OAUTH_REDIRECT_URI env var if set

Testing

The redirect URI should now match Google OAuth credentials:

  • Production: https://sales-agent.scope3.com/admin/auth/google/callback
  • Local: Will auto-add /admin prefix to match nginx routing

Check logs for: OAuth redirect URI: ... to verify correct URL is being used.

- Flask generates /auth/google/callback but nginx expects /admin/auth/google/callback
- Auto-detect and add /admin prefix when GOOGLE_OAUTH_REDIRECT_URI not set
- Fixes redirect_uri_mismatch error with Google OAuth
- Add logging to show actual redirect URI being used
@bokelley bokelley merged commit a95a534 into main Oct 28, 2025
9 checks passed
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
…textprotocol#651)

- Flask generates /auth/google/callback but nginx expects /admin/auth/google/callback
- Auto-detect and add /admin prefix when GOOGLE_OAUTH_REDIRECT_URI not set
- Fixes redirect_uri_mismatch error with Google OAuth
- Add logging to show actual redirect URI being used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants