How to set up social connection with Twitter
Adding social connection with Twitter to your app with Clerk is simple - you only need to set the Client ID, Client Secret and Authorized redirect URI in your instance settings.
To make the development flow as smooth as possible, Clerk uses preconfigured shared OAuth credentials and redirect URIs for development instances - no other configuration is needed.
For production instances, you will need to generate your own Client ID and Client Secret using your Twitter account.
The purpose of this guide is to help you create a Twitter account and a Twitter OAuth app - if you're looking for step-by-step instructions using Clerk to add social connection (OAuth) to your application, follow the Social connection (OAuth) guide.
Before you start
- You need to create a Clerk Application in your Clerk Dashboard. For more information, check out our Set up your application guide.
- You need to have a Twitter Application set up so it can be used for Social connection. If you don't have a Twitter Application, click here for instructions on how to create one. If you already have one, please go to your Twitter app settings and ensure that the "Allow this app to be used to Sign in with Twitter?” option is enabled.
Configuring Twitter social connection
If you don't have an existing Twitter Application you've set up for social connection, you need to register a new one at the Twitter Developer Portal. Note that the process requires approval from Twitter before your new application can be used.
To do so, go to "Projects & Apps" and click "+ Create App" to create a new application. After entering a name, you'll be presented with your app's credentials; API Key and API Secret. Copy those values; we're going to use them in a while.
You will need your application to be approved for elevated status to be able to use it with Clerk. You can apply for the status in Twitter developer dashboard
Go to the Social Connections page and enable Twitter. In the modal that opened, ensure Use custom credentials is enabled and paste the API Key and API Secret values which we copied in the previous step, into the API key and API secret key respectively. Then, copy the Authorized redirect URI, we're going to need it shortly after.
Navigate to your application settings screen and scroll down to the User authentication settings section and click Set up.
In the next screen you'll be presented with the user authentication settings. Make sure that both OAuth 1.0a and Request email address from users are enabled.
Also, enter the Authorized Redirect URI that we grabbed in the previous step from your Clerk instance's settings and insert it in the Callback URI setting. Your app's settings should like similar to the ones below. Fill any other required fields and click save. Your Twitter App is now ready.
Don't forget to click Apply in the Clerk dashboard. Social connection with Twitter is now configured.