If your desired provider is not directly supported, use the Generic OAuth Plugin for custom integrations.
Configuring social providers
ProvideclientId and clientSecret for each provider you want to enable:
auth.ts
Usage
Sign in
Link an account
Get access token
When you callgetAccessToken, the token is automatically refreshed if it has expired.
Get provider account info
Retrieve provider-specific account details:Requesting additional scopes
You can request additional OAuth scopes after initial sign-up by callinglinkSocial with the same provider. This triggers a new OAuth flow requesting only the extra scopes while maintaining the existing account link.
Requires Better Auth v1.2.7 or later. Earlier versions may return a “Social account already linked” error when linking an existing provider for additional scopes.
Passing additional data through the OAuth flow
Pass arbitrary data through the OAuth flow without storing it in the database. This is useful for referral codes, analytics sources, and other temporary metadata.Accessing additional data in hooks
Additional data is available in hooks during the OAuth callback viagetOAuthState:
auth.ts
Accessing additional data in database hooks
auth.ts
Provider options
scope
Specify the OAuth scopes to request:
auth.ts
redirectURI
Override the default callback URL (/api/auth/callback/{providerName}):
auth.ts
mapProfileToUser
Map the provider profile to your user object. Useful for populating additional fields:
auth.ts
To pass additional fields via
mapProfileToUser, configure user.additionalFields in your auth config. See Extending the core schema.refreshAccessToken
Provide a custom token refresh function for built-in social providers:
auth.ts
getUserInfo
Override the default user info retrieval with a custom implementation:
auth.ts
prompt
Control the authorization prompt behavior:
auth.ts
disableImplicitSignUp
When true, new users can only be created when requestSignUp: true is explicitly passed during sign-in:
auth.ts
disableDefaultScope
Remove the provider’s default scopes (usually email and profile) and use only the scopes you specify:
auth.ts
overrideUserInfoOnSignIn
When true, updates the user record in the database with fresh data from the provider on every sign-in. Defaults to false.
disableSignUp
Prevents new user accounts from being created via this provider. Existing users can still sign in.
disableIdTokenSignIn
Disables ID token-based sign-in for providers that support it (e.g., Google, Apple). Enabled by default for those providers.
clientKey
Used by providers like TikTok that use clientKey instead of clientId:
auth.ts