Skip to main content
OAuth authentication allows users to sign in with their existing social accounts. This guide shows you how to implement OAuth with the SnackBase JavaScript SDK.

Supported OAuth Providers

SnackBase supports the following OAuth providers:
  • Google
  • GitHub
  • Microsoft
  • Apple

OAuth Flow

1. Generate Authorization URL

Create the OAuth authorization URL for the provider:

2. Redirect User to OAuth Provider

3. Handle OAuth Callback

After the user approves the authorization, they’ll be redirected back to your application with a code in the URL. Exchange this code for an access token:

Complete OAuth Implementation

Frontend (Browser)

With React Router

OAuth Provider Configuration

Google OAuth

GitHub OAuth

Microsoft OAuth

Apple OAuth

Each provider must be configured in your SnackBase admin panel with the appropriate client ID and secret.

Custom Redirect URI

Specify a custom redirect URI:

State Parameter

Include a state parameter for security:

Complete Example with Multiple Providers

Server-Side OAuth

For Next.js and other server-side frameworks:

Linking OAuth to Existing Accounts

Link an OAuth provider to an existing email/password account:

Error Handling

Handle common OAuth errors:

OAuth vs Email/Password

Consider these factors when choosing between OAuth and email/password:

Next Steps