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.
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:
- In the Clerk Dashboard, navigate to the SSO connections page.
- Select the Add connection button, and select For all users.
- In the Choose provider dropdown, select X/Twitter.
- 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:
- 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.
- 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.
- Select App settings. You'll be redirected to your app's Settings tab.
- Under User authentication settings, next to User authentication not set up, select Set up. You'll be redirected to the User authentication settings page.
- Under App permissions, choose the permissions you want to request from your user. At minimum, select the Read permission.
- Under Type of App, select Web App, Automated App or Bot.
- Under App info, in the Callback URI / Redirect URL field, paste the Callback URI / Redirect URL value you copied from the Clerk Dashboard.
- Complete any other required fields, such as the Website URL.
- 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
- 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.
- Select Add connection.
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.
- In the Clerk Dashboard, navigate to the Account Portal page.
- Next to the Sign-in URL, select Visit. The URL should resemble:
- For development –
https://your-domain.accounts.dev/sign-in
- For production –
https://accounts.your-domain.com/sign-in
- Sign in with your connection's credentials.
Feedback
Last updated on