OAuth
OAuth sign-in with Google, Auth0, and Okta.
BetterForms currently supports OAuth login with:
googleauth0okta
Use OAuth when you want the provider to authenticate the user while BetterForms still creates or updates the app user and signs them into the app.
What You Need
OAuth credentials configured for the app or tenant
A
Users.oauthIdfield in your helper file, available on theUserslayoutA callback page with the navigation slug
auth/oauthauthLoginOauthon that page'sonFormLoad
If you want BetterForms to create users who do not already exist, you also need the onBeforeRegistration server hook.
Provider Callback URL
In your OAuth provider settings, use this callback pattern:
https://your.domain.com/oauth/{provider}/callbackExamples:
https://your.domain.com/oauth/google/callbackhttps://your.domain.com/oauth/auth0/callbackhttps://your.domain.com/oauth/okta/callback
Typical Flow
Add a button or link that navigates to
/oauth/{provider}.The provider authenticates the user and returns to BetterForms.
BetterForms redirects the browser to your
auth/oauthpage.Your
auth/oauthpage runsauthLoginOauth.BetterForms stores the token and continues through the normal login flow.
Callback Page
Add authLoginOauth to the page's onFormLoad action:
oauthLoginHook is a legacy alias and is still supported, but authLoginOauth is the preferred name.
How User Matching Works
BetterForms looks up users by email from the provider response.
If the user already exists, BetterForms updates
oauthIdwhen needed and signs the user in.If the user does not exist, BetterForms calls
onBeforeRegistration.New user creation only continues when that hook returns
model.createUser = true.New users created through OAuth are automatically verified.
Minimal Login Example
Start the flow with a path action:
Notes
If OAuth login fails, BetterForms returns an
errorMessageto the callback page andauthLoginOauthsends it through the normal BetterForms error pipeline.Any query params you append to the initial OAuth URL are also available to
onBeforeRegistrationif you need them for registration logic.For an Auth0-specific walkthrough, see Setting Up Auth0.
Last updated
Was this helpful?