Skip to main content

Sign-in methods

Besides email and password, users can sign in with passkeys, which need no configuration, and with the SSO and social providers you set up under Sign-in: Google, Microsoft, GitHub, Apple and any OpenID Connect provider. Everyone with a password can turn on two-factor authentication (authenticator app plus backup codes) in their profile.

Redirect URIs​

Register these redirect URIs with the provider, with your BETTER_AUTH_URL in front:

ProviderRedirect URI
Google/api/auth/callback/google
Microsoft/api/auth/callback/microsoft
GitHub/api/auth/callback/github
Apple/api/auth/callback/apple
Your OIDC IdP/api/auth/callback/oidc

For OIDC, request the scopes openid email profile. PostPin uses PKCE.

Existing accounts​

A first SSO sign-in with the email of an existing account connects the two, but only if the provider reports the email as verified and the PostPin account's email is verified too. Otherwise the user logs in with their password and connects the provider under Profile › Sign-in & security. A first SSO sign-in with a new email creates an account.

Passkeys​

Passkeys need HTTPS (or localhost) and are bound to the host name of BETTER_AUTH_URL. Changing that host name invalidates every passkey.

SSO-only instances​

With DISABLE_PASSWORD_LOGIN=true, the login page shows only the providers and Sign in with a passkey, the sign-up page only the providers. Existing users with a password sign in through a provider with the same verified email, or with a passkey they added before.

Apple​

"Sign in with Apple" needs a paid Apple developer account. Create an App ID with Sign in with Apple, a Services ID (your APPLE_CLIENT_ID) with your domain and the redirect URI above, and a key for Sign in with Apple. Apple's client secret is a JWT signed with that key, valid for at most 6 months. The script apple-client-secret.mjs from the repository creates it and needs nothing but Node.js:

node apple-client-secret.mjs AuthKey_XXXX.p8 <team id> <key id> <services id>

and set a reminder to create a new one before it expires. Users who hide their email get a @privaterelay.appleid.com address. Apple only forwards mail to it from senders you register under Sign in with Apple for Email Communication, so register your SMTP_MAIL_FROM address there.