How to connect X (Twitter) to Composio

4 min read

Composio connects AI agents to X (Twitter) so they can work with posts, profiles and other account features using the permissions you approve.

This guide shows how to create an X OAuth app and connect it to Composio. Composio-managed OAuth is unavailable for this toolkit, so you need your own X developer credentials. X API usage follows X’s access and billing requirements.

Part 1: Create your X OAuth app

Step 1: Create an app in the X Developer Console

Sign in to the X Developer Console. Open Apps → Create App. Enter your Application Name and select at least one existing project under Project Access. Select the appropriate environment and click Create.

Open Apps in the X Developer Console.Enter the app name and link an existing project before creating the app.

Step 2: Enable OAuth 2.0 user authentication

Open the app and select Settings to reach User authentication settings. In the older console, select Set up or Edit under that heading.

Under App permissions, choose the access your workflow needs. Select the OAuth 2.0 scopes later in Composio.

For Type of App, select Web App, Automated App or Bot. This confidential client type enables the OAuth 2.0 credentials after you save the user authentication settings.

Select a confidential web or automated app; choose permissions for your workflow.

Step 3: Register the Composio callback

Under App info, add this exact Callback URI / Redirect URL:

https://backend.composio.dev/api/v1/auth-apps/add

Enter your application’s public Website URL. Complete any other fields X marks as required, then select Save Changes. The callback must match the Composio Redirect URI exactly, including its path and trailing slash.

The Composio production callback registered in the X app.

Step 4: Get the OAuth 2.0 Client ID and Client Secret

After saving the user authentication settings, open Keys & Tokens. Save the Client ID and Client Secret from OAuth 2.0 Keys. Also save the Bearer Token from App-Only Authentication for the same app. Keep these values private when they are issued.

OAuth 2.0 Client ID and Client Secret are separate from the app-only Bearer Token.

The API Key / API Key Secret shown at app creation are not the OAuth 2.0 Client ID / Client Secret. This guide uses OAuth 2.0 only.

Part 2: Connect X in Composio

Step 1: Create a custom auth config

Use the product switcher to open Platform. In your Composio developer project, open Auth Configs → Create. Search for Twitter, select the toolkit and enter a config name.

Open Platform, create an auth config and select Twitter.Name the X OAuth auth config.

Use OAuth 2.0. Enter your app’s Client id and Client secret. Enter its app-only Bearer Token in Application Bearer Token. All three values must come from the same X app.

Application Bearer Token, production callback and the three scopes for the read-only example.

Keep Redirect URI identical to the callback registered in X.

Step 2: Choose scopes for your workflow

Choose only the scopes needed by the tools you plan to use. The minimum scopes for the read-only profile and post example are tweet.read and users.read. Add offline.access if you need Composio to refresh access without another sign-in. Posting also needs tweet.write. Use X’s endpoint-to-scope reference for additional permissions required by your workflow.

Remove preselected scopes you do not need, then select Create Auth Config. Changing a saved scope list does not update permissions on an existing connection; reconnect and review the new consent when your requirements change.

Step 3: Authorize your X account

Open the saved auth config and select Connect Account. Sign in to the X account you want to connect. Review the app name and requested permissions, then select Authorize app if they match your intended workflow.

X consent for reading posts and profiles, with continued access.

Step 4: Confirm the connection is Active

Return to the auth config and open Accounts. Confirm that the connected account shows Active. The auth config’s Enabled label alone does not confirm a connection.

An existing custom X QA connection is marked Active in Composio.

Connection troubleshooting

  • Invalid client: use the OAuth 2.0 Client ID and Client Secret from a confidential Web App or Automated App.

  • Callback mismatch: compare the complete production callback in X and Composio.

  • Missing refresh token: include offline.access and reconnect to grant it.

  • 403 or client-not-enrolled: check the app’s project access and the endpoint’s access requirements in X. Successful OAuth does not guarantee access to every endpoint.

  • Credits or usage-limit error: review the account’s X usage and billing status. OAuth scopes do not replace API access or usage credits.

Share