Skip to content

fix: fix GitHub OAuth redirect URI and URL encoding [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT] - #1438

Open
waterWang wants to merge 1 commit into
SolFoundry:feat/milestone-payoutsfrom
waterWang:fix/github-oauth-redirect-uri
Open

fix: fix GitHub OAuth redirect URI and URL encoding [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT]#1438
waterWang wants to merge 1 commit into
SolFoundry:feat/milestone-payoutsfrom
waterWang:fix/github-oauth-redirect-uri

Conversation

@waterWang

Copy link
Copy Markdown

Description

Fixes #821 — GitHub OAuth sign-in flow returns a 404 when users click "Sign in with GitHub."

Root Cause

Two issues caused the 404:

1. Redirect URI mismatch

The default GITHUB_REDIRECT_URI was set to http://localhost:3000/auth/callback, but the frontend React route is /auth/github/callback (see frontend/src/App.tsx). After GitHub authorization, the redirect hit the wrong route, returning a 404.

2. Missing URL encoding in authorize URL construction

The get_github_authorize_url function constructed the GitHub OAuth URL using raw string concatenation (f-string), which does not URL-encode parameter values. The scope parameter contains a space (read:user user:email) that must be encoded as %20 or + for GitHub to accept the URL. Other parameters like redirect_uri could also contain characters requiring encoding.

Changes

  1. backend/app/services/auth_service.py:
    • Fixed GITHUB_REDIRECT_URI default from /auth/callback to /auth/github/callback to match the frontend route
    • Added from urllib.parse import urlencode import
    • Replaced raw string concatenation with urlencode(params) for proper URL parameter encoding

Verification

  • Redirect URI now matches frontend route: /auth/github/callback
  • Authorize URL parameters are properly URL-encoded
  • No new imports beyond Python stdlib

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.

1 participant