Create an Authentication Provider Registration Handler

Create an Apex registration handler to use with your authentication provider. When users log in to your third-party app with an external single sign-on (SSO) provider, the registration handler creates and updates their user records.

Required Editions
Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience
Available in: Enterprise, Unlimited, and Developer Editions
  1. From Setup, in the Quick Find box, enter Apex, and then select Apex Classes.

  2. Click New.

  3. Fill the class with your registration handler code. You can paste in the code from the example.

  4. Save the class, and note its name.

Here’s an example registration handler that you can use with your Google authentication provider. This class is triggered every time a user logs in with Google. If it’s the user’s first time logging in to your app, the class creates a user in Salesforce and associates them with the Headless Identity Demo profile that you created. The class also added the user to the account that you created earlier. If the user logged in to your app before, the class updates their record with any new information.

This sample code is for demonstration only. Always test code before deploying it to a production environment.