How to setup social login with Twitter


Adding social login with Twitter to your app with Clerk is simple - you only need to set the Client ID 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 Github account and a Github OAuth app - if you're looking for step-by-step instructions using Clerk to add social login (OAuth) to your application, follow the Social login (OAuth) guide.

Before you start

  • You need to create a Clerk Application in your Clerk Dashboard. For more information, check out our Setup your application guide.
  • You need to have a Twitter Application set up so it can be used for Social login. 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 login

If you don't have an existing Twitter Application you've set up for social login, 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.
Go to Clerk Dashboard, select your Application, and navigate to Instances Settings User Management SSO. Click the Manage credentials button under the Twitter provider, select Custom profile and paste the API Key and API Secret values which we copied in the previous step, into the Consumer key and Consumer secret respectively. Then, copy the Authorized redirect URI, we're going to need it shortly after.
After your app in Twitter is created, go to its settings screen and scroll down to the Authentication settings section and click Edit.
Application main settings screen
In the next screen you'll be presented with the authentication settings. Make sure that both Enable 3-legged OAuth 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 URLs setting. Your app's settings should like similar to the ones below.
Twitter app authentication settings
Don't forget to click Apply in the Clerk dashboard. Social login with Twitter is now configured 🔥
Last modified 15d ago