Skip to main content
Docs

Add X/Twitter v2 as a social connection

You will learn the following:

  • Use X/Twitter v2 to authenticate users with OAuth

Enabling OAuth with X/Twitter allows your users to sign up and sign in to your Clerk app with their X/Twitter account.

Clerk doesn't currently support preconfigured shared OAuth credentials for X/Twitter on development instances. You must provide custom credentials for both development and production instances, which involves generating your own Client ID and Client Secret using your X/Twitter Developer account.

Configure for your production instance

To make the setup process easier, it's recommended to keep two browser tabs open: one for the Clerk Dashboard and one for your X/Twitter Developer Portal.

Warning

X/Twitter v2 doesn't currently provide users' email addresses. Users must manually enter their email address when they return to your application after authenticating with X/Twitter.

To make the setup process easier, it's recommended to keep two browser tabs open: one for the Clerk Dashboard and one for your X/Twitter Developer Portal.

Enable X/Twitter as a social connection

To enable X/Twitter as a social connection for your Clerk application:

  1. In the Clerk Dashboard, navigate to the SSO connections page.
  2. Select the Add connection button, and select For all users.
  3. In the Choose provider dropdown, select X/Twitter.
  4. Save the Redirect URI somewhere secure. Keep the modal and page open.

Create an X/Twitter application

When signing up for a new X/Twitter Developer account, you'll be required to describe your app's use cases. After completing this step, you'll be redirected to the Dashboard page. Under Projects, you'll see an automatically generated app with a randomly generated string as its name.

If you want to create a new X/Twitter application, follow these steps:

  1. In the X/Twitter Developer Portal, under Projects, select Add App. You'll be redirected to the App name tab. If you have a Free account, you can only have one app at a time, so you'll need to delete the existing app before being able to create a new one.
  2. Enter your application name and select Next. You'll be redirected to the Keys & Tokens tab where your app's credentials are displayed. However, these credentials aren't needed to set up the X/Twitter social connection with Clerk, as the setup uses the OAuth 2.0 flow, which relies on different credentials.
  3. Select App settings. You'll be redirected to your app's Settings tab.
  4. Under User authentication settings, next to User authentication not set up, select Set up. You'll be redirected to the User authentication settings page.
  5. Under App permissions, choose the permissions you want to request from your user. At minimum, select the Read permission.
  6. Under Type of App, select Web App, Automated App or Bot.
  7. Under App info, in the Callback URI / Redirect URL field, paste the Callback URI / Redirect URL value you copied from the Clerk Dashboard.
  8. Complete any other required fields, such as the Website URL.
  9. Select Save. You'll be redirected to a page that shows your app's Client ID and Client Secret. Save these values somewhere secure.

Set the Client ID and Client Secret in the Clerk Dashboard

  1. Navigate back to the Clerk Dashboard where the modal should still be open. Paste the Client ID and Client Secret values that you saved into the respective fields.
  2. Select Add connection.

Note

If the modal or page is no longer open, navigate to the SSO connections page in the Clerk Dashboard. Select the connection. Under Use custom credentials, paste the values into their respective fields.

The simplest way to test your connection is to visit your Clerk app's Account Portal, which is available for all Clerk apps out-of-the-box.

  1. In the Clerk Dashboard, navigate to the Account Portal page.
  2. Next to the Sign-in URL, select Visit. The URL should resemble:
  • For developmenthttps://your-domain.accounts.dev/sign-in
  • For productionhttps://accounts.your-domain.com/sign-in
  1. Sign in with your connection's credentials.

Feedback

What did you think of this content?

Last updated on