Skip to content

Fix OAuth authentication: Add missing redirect_uri parameter - #112

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/oauth-redirect-uri-missing
Oct 8, 2025
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix/oauth-redirect-uri-missing

Conversation

@ishaileshpant

Copy link
Copy Markdown
Collaborator

🔧 Fix OAuth Authentication Issue

Problem

Users were experiencing "Authentication Failed" errors with the message "The code passed is incorrect or expired" when trying to authenticate with GitHub OAuth.

Root Cause

The OAuth authorization request was missing the redirect_uri parameter, which GitHub requires to match exactly what's configured in the OAuth app settings.

Solution

  • Added redirect_uri parameter to the GitHub OAuth authorization URL
  • Improved error handling for expired OAuth codes with specific user-friendly messaging
  • Enhanced logging for better OAuth debugging and troubleshooting

Changes Made

  1. Modified github-auth.js:
    • Added redirect_uri parameter to OAuth authorization URL
    • Improved error handling for "incorrect or expired" codes
    • Added comprehensive logging for debugging

Technical Details

// Before
const authUrl = `https://github.com/login/oauth/authorize?` +
    `client_id=${this.clientId}&` +
    `scope=${this.scope}&` +
    `state=${this.generateState()}`;

// After  
const redirectUri = this.getCallbackUri();
const authUrl = `https://github.com/login/oauth/authorize?` +
    `client_id=${this.clientId}&` +
    `scope=${this.scope}&` +
    `state=${this.generateState()}&` +
    `redirect_uri=${encodeURIComponent(redirectUri)}`;

Testing

  • OAuth flow now includes proper redirect_uri parameter
  • Error handling provides clear feedback for expired codes
  • Enhanced logging helps with debugging OAuth issues

Impact

  • 🎯 Resolves "The code passed is incorrect or expired" error
  • 🚀 Improves user experience with better error messages
  • 🔍 Enhances debugging capabilities for OAuth issues

Closes: OAuth authentication failures

- Add redirect_uri parameter to GitHub OAuth authorization URL
- Improve error handling for expired OAuth codes with specific messaging
- Add comprehensive logging for OAuth debugging
- Resolves 'The code passed is incorrect or expired' error

The main issue was that the OAuth authorization request was missing the
redirect_uri parameter, which GitHub requires to match exactly what's
configured in the OAuth app settings. This caused authentication failures
and the 'incorrect or expired' error message.
@vercel

vercel Bot commented Oct 8, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
prepguides-dev Ready Ready Preview Comment Oct 8, 2025 6:24pm

@ishaileshpant

Copy link
Copy Markdown
Collaborator Author

/approve

@github-actions
github-actions Bot merged commit 9754d7d into main Oct 8, 2025
11 checks passed
@github-actions

github-actions Bot commented Oct 8, 2025

Copy link
Copy Markdown
Contributor

🚀 Admin-Approved and Auto-Merged!

This PR has been automatically merged to main after admin approval by @ishaileshpant.

✅ **Status**: Merged and deployed
🔗 **Commit**: `9754d7db8d182ef5cdbf28745911a2d5a1b6f056`
📅 **Merged at**: 2025-10-08T18:29:03.964Z
👤 **Approved by**: Admin/Maintainer/Owner

Thank you for your contribution! 🎉

ishaileshpant added a commit that referenced this pull request Oct 8, 2025
- Keep the original working OAuth code without redirect_uri parameter
- This restores the working authentication state from before PR #112
- Resolves conflicts between revert and main branch changes
github-actions Bot added a commit that referenced this pull request Oct 8, 2025
@ishaileshpant
ishaileshpant deleted the fix/oauth-redirect-uri-missing branch October 13, 2025 18:19
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