Skip to content

OAuth Providers

Pulsabase includes a built-in Identity Provider (IDP) that handles social login flows on your behalf. Users can sign in with a third-party provider, and Pulsabase will create (or link) a local user account automatically.

ProviderStatusNotes
GoogleAvailableOIDC-based, returns email + name + avatar
GitHubAvailableOAuth2, returns email + login
MicrosoftAvailableOIDC-based (Azure AD / Entra ID)
Custom OIDCAvailableAny OIDC-compliant provider (Okta, Keycloak, Auth0, etc.)
AppleComing Soon

The OAuth flow is handled entirely server-side by pulsabase-idp:

1. Frontend opens: GET /oauth/projects/{pid}/providers/{provider}/start
↓ IDP generates a random `state` (CSRF protection) and returns:
{ "auth_url": "https://accounts.google.com/o/oauth2/auth?...", "state": "xyz" }
2. Frontend redirects the user to the provider's auth_url
↓ User authenticates with Google/GitHub/etc.
↓ Provider redirects back to your configured callback URL
3. IDP callback: GET /oauth/projects/{pid}/providers/{provider}/callback?code=...&state=...
↓ IDP validates the state (anti-CSRF)
↓ IDP exchanges the code → provider access token
↓ IDP fetches user identity (email, name, avatar)
↓ IDP creates or links the local user account
↓ IDP issues Pulsabase JWT (access_token + refresh_token)
↓ Returns JWT to your frontend

In Dashboard → Authentication → Providers:

  1. Select the provider (Google, GitHub, Microsoft, or Custom OIDC)
  2. Enter the Client ID and Client Secret from the provider’s console
  3. Copy the Callback URL shown in the dashboard and paste it into the provider’s OAuth app settings
  4. Enable the provider and save
  1. Go to Google Cloud Console → Credentials
  2. Click Create Credentials → OAuth client ID
  3. Application type: Web application
  4. Authorized redirect URI: https://your-idp.pulsabase.io/oauth/projects/{project_id}/providers/google/callback
  5. Copy Client ID and Client Secret into the Dashboard

Your frontend starts the OAuth flow by requesting the authorization URL from the IDP:

// Coming soon: pb.auth.signInWithProvider('google')
// For now, use the direct API:
const res = await fetch(
`${pb.idpUrl}/oauth/projects/${pb.projectId}/providers/google/start`,
{
headers: {'X-Api-Key': pb.apiKey}
}
);
const { auth_url, state } = await res.json();
// Save state in sessionStorage for CSRF validation
sessionStorage.setItem('oauth_state', state);
// Redirect the user to Google
window.location.href = auth_url;

After the user authenticates with the third-party provider, they are redirected to your configured callback URL. The IDP then returns a JWT directly:

GET /oauth/projects/{project_id}/providers/google/callback?code=XXXX&state=abc123xyz

The IDP handles the token exchange internally. If the flow is successful, the response contains the same session tokens as a regular sign-in:

{
"access_token": "eyJhbGciOi...",
"refresh_token": "rt_xxxx",
"id_token": "eyJhbGciOi...",
"token_type": "Bearer",
"expires_in": 3600,
"provider": "google"
}

Store these tokens using the SDK’s session management:

// After receiving the tokens from your callback handler:
pb.auth.setSession({ access_token, refresh_token });
MechanismImplementation
CSRF protectionA random state is generated per flow and validated on callback
State expiryOAuth state is valid for 10 minutes only
PKCESupported for public clients (no client_secret)
Account linkingLinked by email or external sub — prevents duplicate accounts
Self-registration controlDashboard setting to disable auto account creation

By default, new OAuth users are automatically registered. You can disable this in Dashboard → Authentication → Settings → Allow Self-Registration.

When disabled:

  • A user can only sign in via OAuth if they already have an account with the same email
  • First-time users from OAuth providers will receive a 403 error
  • This is useful for invite-only or enterprise applications

OAuth sessions behave identically to email/password sessions:

  • The resulting access_token is a standard Pulsabase JWT
  • JWT claims include the user’s sub, email, roles, permissions, and sub_tenant_id
  • The token is used for all database queries and storage operations
  • Token refresh works exactly the same as email sessions