Configure an X (Formerly Twitter) Authentication Provider
Configure an X (formerly known as Twitter) authentication provider so that your users can log in to Salesforce from their X account.
Required Editions
| Available in: Lightning Experience and Salesforce Classic |
| Available in: Enterprise, Performance, Unlimited, and Developer Editions |
| User Permissions Needed | |
|---|---|
| To view the settings: | View Setup and Configuration |
| To edit the settings: | Customize Application AND Manage Auth. Providers |
To configure this authentication provider, complete these steps.
- Set up a registration handler.
- Set up an X app.
- Define an X authentication provider in Salesforce.
- Update your X app to use the callback URL generated by Salesforce as an entry in the X app settings.
- Test the single sign-on (SSO) connection.
- Add the authentication provider to your login page.
Set Up a Registration Handler
To use an authentication provider for single sign-on, you must create a registration handler. The registration handler creates users and updates existing users who access Salesforce via the identity provider. You can set up a registration handler with Apex or Flow Builder. For more information, see Create an Authentication Provider Registration Handler.
Define an X Authentication Provider in Salesforce
To set up an X authentication provider, you need the API key and API key secret from your X app.
- From Setup, in the Quick Find box, enter Auth. Providers, and then select Auth. Providers | New.
- For the provider type, select Twitter.
- Enter a name for the provider.
- Enter the URL suffix, which is used in the client configuration URLs. For example, if the URL suffix of your provider is MyXProvider, your SSO URL is similar to https://mydomain_url or site_url /services/auth/sso/MyXProvider.
- For Consumer Key, use the API key from your X app.
- For Consumer Secret, use the API secret from your X app.
-
To use an Apex registration handler, take these steps.
- For Registration Handler Type, select Apex.
-
For Registration Handler, select an existing Apex class that implements the
Auth.RegistrationHandlerinterface. Or, to create an template for the registration handler, click Automatically create a registration handler template. Edit this class later, and modify the default content before using it.
-
To use a flow for your registration handler, take these steps.
- For Registration Handler Type, select Flow.
- For Registration Handler, select an existing flow of the Identity User Registration flow type.
-
Select a default profile. A default profile is required to run the registration
handler. If you don't specify a default profile here, set the default profile in the
flow itself.
If you use the Authentication Provider User Registration flow template, the profile that you set here is automatically stored in the defaultProfileId variable.
-
Select a default account. If you use your authentication provider for Experience
Cloud sites, this account stores new internal users.
If you use the Authentication Provider User Registration flow template, the profile that you set here is automatically stored in the defaultAccountId variable.
-
For Execute Registration As, select an execution user to run the Apex class or flow.
The user must have the Manage Users permission.
Execute Registration As provides the context in which the registration handler runs. In production, you typically create a system user for the Execute Registration As user. This way, operations performed by the handler are easily traced back to the registration process. For example, if a contact is created, the system user creates it.
-
Optionally, set these fields:
- If you enter a consumer key and consumer secret, the consumer secret is included in SOAP API responses by default. To hide the secret in SOAP API responses, deselect Include Consumer Secret in SOAP API Responses. Starting in November 2022, the secret is always replaced in Metadata API responses with a placeholder value. On deployment, replace the placeholder with your consumer secret as plain text, or modify the value later through the UI.
- For Custom Error URL, enter a URL for the provider to use to report any errors.
-
For Custom Logout URL, enter a URL to provide a specific destination for users
after they log out, if they authenticated using the SSO flow. Use this field to
direct users to a branded logout page or destination other than the default
Salesforce logout page. The URL must be fully qualified with an http or https
prefix, such as https://acme.my.salesforce.com.
Tip Configure single logout (SLO) to automatically log out a user from Salesforce and the identity provider. As the relying party, Salesforce supports OpenID Connect SLO when the user logs out from the identity provider or Salesforce. - To use a portal for X users, select the portal from the Portal dropdown list.
- For Icon URL, add a path to an icon to display as a button on the login page for a site. This icon applies to an Experience Cloud site only. It doesn’t appear on your Salesforce login page or My Domain login URL. Users click the button to log in with the associated authentication provider for the site. Specify a path to your own image, or copy the URL for one of our sample icons into the field.
- To use the Salesforce multi-factor authentication (MFA) functionality instead of your identity provider’s MFA service, select Use Salesforce MFA for this SSO provider. This setting triggers MFA only for users who have MFA applied to them directly. For more information, see Use Salesforce MFA for SSO.
- Save your work.
Several client configuration URLs are generated after defining the authentication provider.
- Test-Only Initialization URL—Admins use this URL to ensure that the third-party provider is set up correctly. The admin opens this URL in a browser, signs in to the third party, and is redirected to Salesforce with a map of attributes.
- Single Sign-On Initialization URL—Use this URL to perform SSO into Salesforce from a third-party using third-party credentials. The user opens this URL in a browser and signs in to the third party. The third party creates a user or updates an existing user. Then the third party signs the user into Salesforce as that user.
- Existing User Linking URL—Use this URL to link existing Salesforce users to a third-party account. The user opens this URL in a browser, signs in to the third party, signs in to Salesforce, and approves the link.
- Callback URL—Use this URL for the endpoint that the authentication provider calls back to for configuration. The authentication provider has to redirect to the callback URL with information for each client configuration URL.
Client configuration URLs support additional request parameters that enable you to direct users to log in to specific sites, obtain customized permissions from the third party, or go to a specific location after authenticating.
Update Your X App
After you define the X authentication provider in Salesforce, return to your X app. Update your app to use the Salesforce-generated callback URL as the callback URL value in your X app settings.
Add the Authentication Provider to Your Login Page
Configure your login page to show the authentication provider as a login option. Depending on whether you’re configuring SSO for an org or Experience Cloud site, this step is different.
- For orgs, see Add an Authentication Provider to Your Org's Login Page.
- For Experience Cloud sites, see Add an Authentication Provider to Your Experience Cloud Site’s Login Page.

