Configure Generic OAuth
Register the exact callbackhttps://your-app.example/api/auth/callback/ofauth for your Better Auth base URL and base path. Check the callback URL generated by your pinned Better Auth version.
allowDifferentEmails is an explicit policy for this signed-in linking journey. The provider identity must still satisfy Better Auth’s verified-email policy. Different-email permission does not trust an unverified or absent provider email. Preserve your application’s policy if different-email linking is inappropriate. Do not add blanket trustedProviders or automatically replace the user’s login identity or profile. Configure token encryption through your supported Better Auth storage settings.
Link from an existing session
Start linking from your signed-in application session. Generic OAuth providers use the core client’slinkSocial; no client plugin is needed:
identity:read permits owner profile access; it does not grant an account operation.
Userinfo returns matching stable id and sub. Email is returned only when known and permitted, with truthful verification. Guest API delegation needs no forced signup or fabricated email. A profile-based linking journey must satisfy Better Auth’s identity requirements or complete OFAuth’s supported identity step explicitly.
Use the current access token
On your backend, call Better Auth’s supported token API for the linked account:accountId when obtaining the token. List the shared accounts and have the user choose which account to use.
Do not add a custom token exchange, OFAuth refresh table, PostgreSQL advisory lock, or a second SDK credential manager. Concurrent refreshes return independent access tokens and the same client-bound refresh token.
For a revoked refresh grant, offer account linking again. For a provider session error, reconnect that linked account. These are separate recovery actions.