Skip to main content
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.
This endpoint redirects users to the OAuth provider’s authorization page. Users will be redirected back to your application after authorization.

Query Parameters

string
required
OAuth provider to use for authentication.Supported providers:
  • google - Google OAuth
  • github - GitHub OAuth
  • facebook - Facebook OAuth
  • twitter - Twitter OAuth
  • linkedin - LinkedIn OAuth
  • microsoft - Microsoft OAuth
  • apple - Apple OAuth
  • discord - Discord OAuth
string
URL to redirect to after successful authentication. Must be a whitelisted URL.
string
Space-separated list of OAuth scopes to request. If not provided, uses default scopes for the provider.
string
Custom state parameter to include in the OAuth flow for CSRF protection.

Response

This endpoint returns a 302 Found redirect response to the OAuth provider’s authorization URL.
string
The OAuth provider’s authorization URL where the user should be redirected

Error Responses

OAuth Providers

Google OAuth

Default scopes: openid email profile

GitHub OAuth

Default scopes: user:email

Facebook OAuth

Default scopes: email public_profile

Microsoft OAuth

Default scopes: openid email profile

Apple OAuth

Default scopes: 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

  • Always use HTTPS in production
  • Implement proper state validation
  • Whitelist redirect URLs
  • Use minimal required scopes
  • Validate OAuth responses
  • Provide clear provider selection
  • Show loading states during redirects
  • Handle OAuth errors gracefully
  • Offer alternative authentication methods
  • Remember user’s preferred provider
  • 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

OAuth Callback

Handle OAuth provider callbacks

Login

Traditional email/password login

Signup

Create new user accounts

Logout

End user sessions