Skip to main content

Set up social login with X

The official Logto connector for X (formerly Twitter) social sign-in.

tip:

This guide assumes you have basic understanding of Logto Connectors. For those unfamiliar, please refer to the Connectors guide to get started.

Get started

The X (Twitter) connector enables end-users to sign in to your application using their own X (Twitter) accounts via X OAuth 2.0 authentication protocol.

Create an app in the X Developer Portal

Go to the X Developer Portal and sign in with your X account. If you don’t have an account, you can register for one.

Then, create an app.

Step 1: Navigate to the app creation section.

Once signed in, go to the "Projects & Apps" section and click on "Create App" (or "New App", depending on the interface).

Step 2: Fill in the app details.

Complete the form with the following information:

  • App Name: Provide a unique and descriptive name for your application.
  • Application Description: (Optional) Add a brief description of what your app does.
  • Website URL: Enter the URL of your application's homepage.
  • Callback URL / Redirect URI: In our case, this will be ${your_logto_endpoint}/callback/${connector_id}. e.g. https://foo.logto.app/callback/${connector_id}. The connector_id can be found on the top bar of the Logto Admin Console connector details page.

Step 3: Select permissions and scopes.

Choose the permissions that your app requires. For social sign-in via X, make sure you enable the necessary scopes tweet.read and users.read.

Step 4: Save your app.

Click "Create" or "Save" to register your app.

After creation, navigate to your app’s "Keys and tokens" section to retrieve your OAuth 2.0 Client ID and Client Secret.

Configure your connector

In your Logto connector configuration, fill out the following fields with the values obtained from your App's "Keys and tokens" page's "OAuth 2.0 Client ID and Client Secret" section:

  • clientId: Your App's Client ID.
  • clientSecret: Your App's Client Secret.

scope is a space-delimited list of scopes. If not provided, the default scope is tweet.read users.read.

Config types

NameType
clientIdstring
clientSecretstring
scopestring

Test X (Twitter) connector

That's it. The X (Twitter) connector should be available now. Don't forget to Enable social connector in sign-in experience.

Reference

X developer documentation

X OAuth 2.0 Authorization Code Flow with PKCE