This guide will help you set up and configure the necessary components for your application.
Before starting, make sure you have:
- A GitHub account
To enable GitHub OAuth authentication in your application, you'll need to obtain a GitHub Client ID and Client Secret.
- Go to GitHub Developer Settings
- Click on "OAuth Apps" in the left sidebar
- Click "New OAuth App" button
Fill in the required information:
- Application name: Enter a descriptive name for your application
- Homepage URL: Your application's main URL (e.g.,
https://yourapp.com) - Application description: Brief description of your app (optional)
- Authorization callback URL: The URL GitHub will redirect to after authorization
- For development:
http://localhost:3000/auth/github/callback - For production:
https://yourapp.com/auth/github/callback
- For development:
Note: On this project, callback URL is set to frontend URL, which is http://localhost:3000/auth/github/callback for development.
- After creating the OAuth app, you'll see your Client ID displayed
- Click "Generate a new client secret" button
- Copy and securely store both:
GITHUB_CLIENT_ID(client ID)GITHUB_CLIENT_SECRET(client secret)
Create a .env file in your project root and add:
GITHUB_CLIENT_ID=your_client_id_here
GITHUB_CLIENT_SECRET=your_client_secret_hereYou can modify your OAuth app settings anytime:
- Go back to GitHub Developer Settings
- Click on your OAuth app name
- Update URLs or regenerate secrets as needed
Invalid Client ID/Secret:
- Double-check your environment variables
- Ensure no extra spaces or characters
- Verify the OAuth app is active
Callback URL Mismatch:
- Ensure callback URL in GitHub matches your application
- Check for HTTP vs HTTPS differences
- Verify port numbers for local development
Authorization Denied:
- Check OAuth app permissions
- Ensure the app isn't suspended
- Verify user has access to the repository (if applicable)