OAuth
OAuth Authorize
Initiate OAuth authorization flow
GET
Initiate the OAuth 2.0 authorization flow by redirecting users to third-party OAuth providers. This endpoint supports multiple OAuth providers including Google, GitHub, Facebook, and others.
Default scopes:
Default scopes:
Default scopes:
Default scopes:
Default scopes:
This endpoint redirects users to the OAuth provider’s authorization page. Users will be redirected back to your application after authorization.
Query Parameters
OAuth provider to use for authentication.Supported providers:
google- Google OAuthgithub- GitHub OAuthfacebook- Facebook OAuthtwitter- Twitter OAuthlinkedin- LinkedIn OAuthmicrosoft- Microsoft OAuthapple- Apple OAuthdiscord- Discord OAuth
URL to redirect to after successful authentication. Must be a whitelisted URL.
Space-separated list of OAuth scopes to request. If not provided, uses default scopes for the provider.
Custom state parameter to include in the OAuth flow for CSRF protection.
Response
This endpoint returns a302 Found redirect response to the OAuth provider’s authorization URL.
The OAuth provider’s authorization URL where the user should be redirected
Error Responses
OAuth Providers
Google OAuth
openid email profile
GitHub OAuth
user:email
Facebook OAuth
email public_profile
Microsoft OAuth
openid email profile
Apple OAuth
name email
Implementation Examples
React OAuth Login Component
OAuth State Management Hook
OAuth Provider Configuration
Node.js OAuth Redirect Handler
Security Considerations
- State Parameter: Always use the state parameter for CSRF protection
- Redirect URL Validation: Ensure redirect URLs are whitelisted
- Scope Limitation: Request only necessary OAuth scopes
- HTTPS Required: Use HTTPS in production for secure redirects
- Provider Configuration: Properly configure OAuth apps with providers
OAuth Flow Diagram
Best Practices
Security
Security
- Always use HTTPS in production
- Implement proper state validation
- Whitelist redirect URLs
- Use minimal required scopes
- Validate OAuth responses
User Experience
User Experience
- Provide clear provider selection
- Show loading states during redirects
- Handle OAuth errors gracefully
- Offer alternative authentication methods
- Remember user’s preferred provider
Error Handling
Error Handling
- Handle network errors during redirects
- Provide fallback authentication methods
- Log OAuth errors for debugging
- Show user-friendly error messages
- Implement retry mechanisms
Testing
Unit Tests
Related Endpoints
OAuth Callback
Handle OAuth provider callbacks
Login
Traditional email/password login
Signup
Create new user accounts
Logout
End user sessions