Skip to content

Provider Integration

Provider configuration has two layers. They are independent and both must be in place for a provider to be usable.

LayerWhereScopeConfiguration Method
Credentials.env fileGlobal (all applications)Environment variables
ToggleAdmin ConsolePer applicationAuth Policy → allowed_providers

A provider must have its credentials configured in .env first. Once configured, it becomes globally available and can be toggled on or off per application in the Auth Policy section.

.env
GOOGLE_CLIENT_ID=xxx
GOOGLE_CLIENT_SECRET=xxx
|
betterAuth({
socialProviders: {
google: { clientId: xxx, clientSecret: xxx }
}
})
|
Better Auth registers OAuth routes:
GET /api/auth/oauth2/callback/google
|
User clicks "Sign in with Google" on any SaaS
→ Redirected to accounts.google.com
→ Google calls back to /api/auth/callback/google
→ Better Auth verifies the code
→ User is authenticated

Once a provider is configured globally, each application’s Auth Policy controls whether the provider is available for that specific application:

Application A (Acme)
allowed_providers: ["email", "google"]
→ "Sign in with Google" appears on Acme's login page
Application B (gamma)
allowed_providers: ["email"]
→ "Sign in with Google" does NOT appear on niche's login page

This is enforced by the AllowedProviders policy in the SignupPolicyChain. Even if a user somehow reaches /api/auth/sign-in/social for a disabled provider, the policy engine rejects the request.

ProviderRequiresStatus
Email + PasswordNothingAlways enabled
GoogleGOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRETConfigurable
Apple Sign InAPPLE_CLIENT_ID, APPLE_TEAM_ID, APPLE_KEY_ID, APPLE_PRIVATE_KEYConfigurable
GitHubGITHUB_CLIENT_ID, GITHUB_CLIENT_SECRETConfigurable