Skip to content

[BUG] GitHub OAuth access token expiry is not checked before API calls, causing silent 401 failures after token refresh #2842

Description

@anshul23102

Problem

The dashboard uses a GitHub OAuth access token stored in the user session. GitHub access tokens for OAuth apps do not expire by default, but fine-grained personal access tokens and GitHub Apps tokens do expire. Additionally, users can revoke authorization at any time in their GitHub settings. When an expired or revoked token is used to call the API, GitHub returns HTTP 401, but the dashboard does not distinguish this from a network error: it either shows stale data or a generic error message, leaving users confused about why their stats are missing.

Steps to Reproduce

  1. Authenticate with GitHub OAuth
  2. Manually revoke the application's access in GitHub Settings > Applications
  3. Reload the dashboard
  4. Observe the generic error state rather than a "reconnect GitHub" prompt

Proposed Fix

Inspect the HTTP status and X-OAuth-Scopes header on every GitHub API response:

if (response.status === 401) {
  await invalidateSession(userId);
  redirect("/auth/github"); // prompt re-authentication
}

Show a clear "Your GitHub connection has expired. Reconnect to refresh your stats." banner when this condition is detected.

Complexity: Level 2 | Program: GSSOC '26

Metadata

Metadata

Labels

gssoc:assignedGSSoC: Issue assigned to a contributor

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions