GitHub & Google OAuth
Secure GitHub & Google OAuth authentication integration using passport, passport-google-oauth20 and passport-github2 for Express applications.
Installation Guide
npx servercn-cli@latest add oauth You will be prompted to select a file upload provider:
The CLI will then automatically configure the component based on your selected provider.
Prerequisites
Google Cloud Console Setup
- Go to the Google Cloud Console
- Create/Select a project -> Enable Google+ API
- Create Credentials -> OAuth Client ID -> Web Application
- Authorized Redirect URI:
http://localhost:3000/api/auth/google/callback - Copy Client ID and Client Secret
GitHub OAuth Setup
- Go to GitHub Settings > Developer settings
- New OAuth App
- Authorization callback URL:
http://localhost:3000/api/auth/github/callback - Copy Client ID and Client Secret
Environment Variables
Add to your .env: