Okto Docs
Twitter Authentication

Get X (Twitter) API Keys

Learn how to obtain X API keys for authenticating with the X API.

To authenticate with the X API, you need to obtain API keys from the X Developer Portal. Follow these steps to get your keys:

1. Create a X Developer Account

Visit the X Developer Portal and sign up for a developer account using your X (Twitter) credentials.

X Developer Portal Dashboard

2. Create an App

From the dashboard, navigate to Projects & Apps in the sidebar, then click on Overview. Next, click Create App.

X Developer Portal Dashboard

3. Name Your App

Enter a name for your application. This name will be visible to users when they authorize your app. Click Next to continue.

X Developer Portal Dashboard

4. Save Your API Keys

From this tab, you will find the API Key and the API Secret Key. Copy the first two marked keys: API Key and API Key Secret. You will need these to authenticate via X and get the access token.

X Developer Portal Dashboard

Store these credentials securely. Do not share them publicly or commit them to version control.

5. Configure App Settings

After saving your keys, you'll be taken to your app's settings page. Here you can view your app details and configure additional settings.

X Developer Portal Dashboard

6. Set Up User Authentication

To enable user authentication, click Set up in the User authentication section.

Choosing App Type:

  • Native App: Select this if you are building a mobile or desktop application that runs directly on a user's device (e.g., iOS, Android, Windows, or Mac apps). Native apps are considered public clients and typically cannot keep secrets secure.
  • Web App, Automated App or Bot: Select this if you are building a web application, server-side app, or a bot. These are confidential clients that can securely store secrets and are suitable for most web-based integrations or backend services.

X Developer Portal Dashboard

7. Configure Callback URLs

Configure the callback URLs for your application. These URLs are used by X to redirect users after they authorize your app.

What to enter:

  • Callback URI / Redirect URL: Enter the URL where users should be redirected after they authorize your app. This is usually an endpoint in your app that handles the OAuth callback, such as https://yourapp.com/auth/callback.
  • Website URL: Enter the main website address for your app or service, such as https://yourapp.com. This is shown to users during the authorization process.

X Developer Portal Dashboard

8. Use Your API Keys

You now have everything needed to authenticate with the X API. Refer to the X API documentation for usage examples.


For more information, see X's official documentation.