Create a Custom One-Time Password Delivery Apex Handler
Custom one-time password (OTP) delivery relies on an Apex handler that implements the
Auth.CustomOneTimePasswordDeliveryHandler interface. Your
custom OTP delivery handler calls out to your provider to send an OTP to the user via SMS. You
can customize the content of the SMS message and the short code that the user sees.
Required Editions
Available in: both Salesforce Classic (not available in all orgs) and Lightning
Experience
Available in: Professional, Enterprise, Unlimited, and
Developer Editions
User Permissions
Needed
To define, edit, delete, set security, and set version
settings for Apex classes:
Author Apex
To run Apex tests:
View Setup and Configuration
The custom OTP delivery handler uses the sendOneTimePassword method to send an OTP to the user.
From Setup, click , and then select Developer
Console.
Click File, select New, and then select
Apex Class.
Enter a name for your handler, such as MyCustomOtpHandler.
Develop an Apex handler that implements the Auth.CustomOneTimePasswordDeliveryHandler interface and returns an instance of the
Auth.CustomOneTimePasswordDeliveryResult enum.
To make sure that the handler can successfully call out to the provider to send an SMS
message, test the Apex handler with hard-coded values for the userId, phoneNumber, oneTimePassword, defaultText, networkId, and experienceId. See Testing Apex.
Save the handler.
Next, add the handler to your Experience Cloud site settings.
Did this article solve your issue?
Let us know so we can improve!
Loading
Salesforce Help | Article
Cookie Consent Manager
General Information
Required Cookies
Functional Cookies
Advertising Cookies
General Information
We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required Cookies
Always Active
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional Cookies
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising Cookies
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.