OAuth
Oauth authentication is the protocol that allow users to login to your application using external provider credentials, such as Google, Auth0 or Okta.
Last updated
Was this helpful?
Oauth authentication is the protocol that allow users to login to your application using external provider credentials, such as Google, Auth0 or Okta.
Last updated
Was this helpful?
In order to use OAuth make sure you have the following information from the external provider that will be used.
Client ID;
Secret Key;
Subdomain.
In addition, apps need to be running version BetterForms 2.0.12+ (bf-staging, as of May 2023).
Go to provider's admin console and add your domain as an Allowed Callback URLs, as following.
Select the app where OAuth will be added, click on the ellipsis besides the App name and select App Settings
.
Under Authentication
, toggle the button Enable 3rd Party Authentication
.
Select one of the 3 providers from the dropdown menu, enter Client ID, Client Secret and Subdomain (Scope still not implemented).
Subdomain values vary from provider to provider:
myClientID.apps.googleusercontent.com
N/A
Auth0
mySubdomain.region.auth0.com
mySubdomain.region
Okta
mySubdomain.okta.com
mySubdomain
A new field oauthId
needs to be created in the Users
table.
A before registration hook script can be used to the business file if you want to control whether a user is allowed to register or not.
The script needs to be called onBeforeRegistration
, and by setting createUser
to true on $$BF_Model
will allow users to register to your app via OAuth.
if your integration is older, you may not have a onBeforeRegistration
hook installed.
Update the BF Common Dispatch Script
Users registered via OAuth workflow are automatically verified, so there’s no need to send verification emails.
This page is a new page that needs to be added to the app. Once the user is authenticated with the external user, the request will be redirected to this page, where the JWT token will be generated by calling the action presented below.
The callback lading page must use auth/oauth
as its navigation slug.
In your new callback landing page, add the following actions to your onFormLoad:
If the external provider or internal code returns an error, the error will return as a query parameter errorMessage
, be added to default model.authMessage
key, as well as a console log message.
Add a button or link that redirects to one the following paths
/oauth/google
Auth0
/oauth/auth0
Okta
/oauth/okta
For example, if we were to add Google to our app:
Redirects can be performed by adding a redirect
query param to the URL. You can also pass things like id
's which will appear in the onBeforeRegistration
script in the $$BF_Query
variable.