🚧 FastCMS is under active development — not ready for production use. APIs and features may change without notice.
FastCMS
Authentication

OAuth Authentication

Social login with 29 OAuth providers — Google, GitHub, Microsoft, Discord, and more.

OAuth Authentication

FastCMS supports OAuth authentication with 29 providers, allowing users to sign in with their existing accounts.

Supported Providers

ProviderType
Googlegoogle
GitHubgithub
Microsoftmicrosoft
Appleapple
Discorddiscord
Facebookfacebook
GitLabgitlab
Twitter/Xtwitter
Spotifyspotify
Twitchtwitch
Notionnotion
Linearlinear
OpenID Connectoidc
+ 16 more

Configuration

  1. Navigate to Admin > Settings > OAuth Providers
  2. Click "Add Provider"
  3. Select the provider type
  4. Enter Client ID and Client Secret
  5. Toggle "Enabled" and save

Method 2: Environment Variables

GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret

Method 3: API

POST /api/v1/oauth/providers
Authorization: Bearer ADMIN_TOKEN

{
  "provider_type": "google",
  "name": "Google",
  "client_id": "your-client-id.apps.googleusercontent.com",
  "client_secret": "your-client-secret",
  "enabled": true
}

Setting Up Providers

Google OAuth

  1. Go to Google Cloud Console
  2. Create a project → APIs & ServicesCredentials
  3. Create OAuth 2.0 Client ID (Web application)
  4. Add redirect URI: http://localhost:8000/api/v1/oauth/google/callback
  5. Add credentials via Admin UI

GitHub OAuth

  1. Go to GitHub Developer Settings
  2. Click New OAuth App
  3. Set callback URL: http://localhost:8000/api/v1/oauth/github/callback
  4. Add credentials via Admin UI

OpenID Connect (Generic)

{
  "provider_type": "oidc",
  "name": "My OIDC Provider",
  "client_id": "your-client-id",
  "client_secret": "your-client-secret",
  "extra_config": {
    "discovery_url": "https://your-provider.com/.well-known/openid-configuration"
  }
}

OAuth Flow

1. Initiate OAuth Login

Redirect users to:

GET /api/v1/oauth/{provider}/login

2. Callback

After authorization, FastCMS automatically:

  • Exchanges the code for an access token
  • Fetches the user's profile
  • Creates or updates the user account
  • Returns JWT tokens

Response:

{
  "access_token": "eyJhbGc...",
  "refresh_token": "eyJhbGc...",
  "token_type": "bearer",
  "user": {
    "id": "user-uuid",
    "email": "user@gmail.com",
    "name": "John Doe",
    "verified": true,
    "oauth_provider": "google"
  }
}

Frontend Integration

<a href="http://localhost:8000/api/v1/oauth/google/login">
  Sign in with Google
</a>
<a href="http://localhost:8000/api/v1/oauth/github/login">
  Sign in with GitHub
</a>

Dynamic provider buttons:

const providers = await fetch('/api/v1/oauth/providers/enabled').then(r => r.json());

providers.forEach(provider => {
  const button = document.createElement('a');
  button.href = `/api/v1/oauth/${provider.type}/login`;
  button.textContent = `Sign in with ${provider.name}`;
  loginContainer.appendChild(button);
});

OAuth with Auth Collections

GET /api/v1/oauth/{provider}/login?collection=customers

OAuth Behavior Settings

SettingDefaultDescription
oauth_enabledtrueEnable OAuth authentication
oauth_auto_create_usertrueAuto-create user on first OAuth login
oauth_link_by_emailtrueLink OAuth to existing user by email

Security Notes

  1. HTTPS in Production — always use HTTPS URLs for OAuth redirects
  2. State Parameter — FastCMS includes CSRF protection via state parameter
  3. Redirect URI Validation — ensure redirect URIs match exactly in provider settings

Troubleshooting

ErrorSolution
Redirect URI mismatchEnsure the redirect URI exactly matches what's in provider settings
Access deniedUser denied permission — check scopes requested
Invalid clientVerify Client ID and Client Secret
Provider not foundCheck /api/v1/oauth/providers/enabled for active providers

On this page