# Leaked X (Twitter) API Key and Secret? Regenerate

> X (Twitter) API key and secret exposed on GitHub? Regenerate them in the developer console and check app usage. Step-by-step guide.

Source: https://leakwatch.net/secrets/x-twitter-api-key-secret

---

[LeakWatch](/)

[Product](/product)[Live feed](/leaks)[Guides](/secrets)[Blog](/blog)[Free scan](/)

1.  [Home](/)
2.  [Secrets](/secrets)
3.  X (Twitter) API Key and Secret

Messaging · Secret guide

# Leaked X (Twitter) API Key and Secret: what to do in the first hour

High severityDetected onlyLast verified October 30, 2026 · 5 min read

The API key and API secret of an X developer app (also called the consumer key and consumer secret) are the base credentials of that app. They identify the app to the X API and are used to sign OAuth 1.0a requests. X’s own documentation says they can be used to generate other credentials, such as user access tokens and bearer tokens. So a leaked pair is not just a way to spend your API quota: combined with a sign-in flow or an access token, it lets someone act as your application. Regenerate the pair first, then check what the app did.

[Check your GitHub account for leaked secrets — free](/)

Provider

Twitter

Severity

High

Impact

SaaS account access and billing

Checked live by LeakWatch

No

## What an X API key and secret look like

The two values come as a pair of random strings made of letters and digits, with no prefix. The key is shorter than the secret:

```text
API key      25 characters, letters and digits (masked)
API secret   50 characters, letters and digits (masked)
```

Because there is no prefix, context is what identifies them: variables such as `TWITTER_API_KEY`, `TWITTER_API_SECRET`, `TWITTER_CONSUMER_KEY`, `X_API_KEY`, `X_API_SECRET` or `X_CONSUMER_SECRET`, or arguments of an OAuth 1.0a client library. The pair is separate from the other X credentials: a bearer token starts with a long run of `A` characters, and a user access token is a number followed by a dash and a string, with its own access secret. A file that leaked the key and secret frequently holds those as well, so check for them. They are handled in their own guides.

## How X API keys and secrets get leaked

-   **Bots and automation scripts.** A posting or monitoring bot with the consumer key and secret as constants.
-   **Environment files.** `TWITTER_API_KEY` and `TWITTER_API_SECRET` in a `.env` file committed with the rest of the project.
-   **Tutorial and notebook output.** A data-collection notebook run with real credentials and published with its cells.
-   **Mobile and front-end code.** A client that signs requests itself, which means the secret ships inside the app or the bundle where anyone can extract it.
-   **Shared snippets and issues.** A code sample or a configuration file pasted into a support request.

## What to do in the first hour

1.  **Find the app.** In the X developer console, open the app that the key belongs to. If several apps exist, match the key by its first characters, shown in the app’s keys and tokens page.
2.  **Regenerate the API key and secret** from that page. X’s documentation notes that the values are displayed only once, so copy them straight into your secret manager. Regenerating replaces the old pair.
3.  **Deploy the new pair** to every service that uses it and run one request to confirm it works. Expect user access tokens to need regenerating too, since they are tied to the app credentials.
4.  **Regenerate the other credentials of the app** (bearer token, access token and secret) if they were in the same file or if you cannot tell.
5.  **Review usage.** Look at the app’s usage figures for the period since the exposure and compare them with your normal volume. Check the account the app posts as for posts, replies or direct messages you did not write.
6.  **Check app settings.** Review the app’s permissions (read, read and write, direct messages), the callback URLs and the website URL. A changed callback URL is a way to capture tokens from sign-in flows.
7.  **Clean up the code** and rewrite history if the repository was public. See [I accidentally pushed an API key to GitHub](/blog/i-accidentally-pushed-an-api-key-to-github).

Not sure what else leaked from the same repository? [Run a free scan](/).

[Not sure what else leaked? Run a free scan.](/)

## Revoke it at X

The key and secret are managed in the X developer console, after you sign in with the account that owns the app. Open the apps list, choose the app, and go to its keys and tokens tab, where the API key and secret can be regenerated. See X’s documentation page on the [API key and secret](https://docs.x.com/fundamentals/authentication/oauth-1-0a/api-key-and-secret). A person has not confirmed the exact menu wording for this guide, and X has renamed the portal and its pages several times, so if what you see differs, look for the section where an app’s keys are listed.

## How LeakWatch detects it

Four rules cover this pair. All are case-insensitive and need a name before an assignment sign (`=`, `:` or `=>`), optional quotes, and a value that ends at a quote, whitespace, a semicolon or the end of the line. “Twitter API Key” and “Twitter API Secret” need the word `twitter` first, then a short label of up to about 20 characters, then a value of exactly 25 letters or digits for the key, and exactly 50 for the secret. “X (Twitter) API Key” and “X (Twitter) API Secret” do the same for the rebranded names: they need `x api` or `x consumer`, with a space, underscore, dash or nothing between (so `X_API_KEY` and `X_CONSUMER_SECRET` match), preceded by a non-word character so that names such as `nginx_api` do not trigger. Values of another length, or names with no `twitter` or `x api` context, are not reported. The key rules have severity **high**, and so do the secret rules. These types are not checked live: LeakWatch does not call the X API with the values, so a hit shows the right shape in context, not that the pair still works.

LeakWatch detects this format but does **not** check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.

## FAQ

Can someone post on my account with only the API key and secret?

Not by themselves, because posting as a user needs a user access token. But the pair lets them act as your app, and with any leaked access token the two work together.

Are the key and secret the same as the bearer token?

No. The bearer token is an app-only credential generated from the pair. Regenerating the pair does not replace a leaked bearer token automatically, so check it too.

Do I need to tell my users?

If tokens for your users were stored with the credentials or the app posted unwanted content, yes. Otherwise a regenerated pair and a review of the usage are usually enough.

## Related

-   [X (Twitter) Bearer Token](/secrets/x-twitter-bearer-token)
-   [X (Twitter) Access Token and Secret](/secrets/x-twitter-access-token-secret)
-   [Facebook Access Token](/secrets/facebook-access-token)
-   [I accidentally pushed an API key to GitHub](/blog/i-accidentally-pushed-an-api-key-to-github)
-   [Which vendors leak most this week](/leaks/trends)
-   [All secret guides](/secrets)

[Get alerted next time a secret leaks — create a free account](/)

LeakWatch is not affiliated with Twitter.

![Gabriel Diyan, founder of LeakWatch](/brand/Photo-Gabriel-Diyan.webp)

Gabriel Diyan (0xCr0c0)

Cybersecurity student, founder of LeakWatch. I built and run the scanner described here — the detection patterns, the false-positive classifier and the provider validators are mine. [More about who I am](/about).

[GitHub](https://github.com/Leakwatch-Scan) · [X](https://x.com/LeakwatchScan) · [LinkedIn](https://www.linkedin.com/in/gabriel-diyan-80a378375) · [GitHub (personal)](https://github.com/crocogab)

LeakWatch

Secrets leak into public commits every minute. This watches the forges for yours. Built and run by [Gabriel Diyan](/about), a cybersecurity student — [why LeakWatch exists](/about).

Scan

-   [Product](/product)
-   [Live feed](/leaks)
-   [Trends](/leaks/trends)
-   [API docs](/docs)
-   [CI/CD](/docs?tab=ci)

Read

-   [Blog](/blog)
-   [Secret guides](/secrets)
-   [Changelog](/changelog)
-   [About](/about)

Verify

-   [Security](/security)
-   [Privacy](/privacy)
-   [Terms](/terms)
-   [Legal](/legal)
-   [Contact](/contact)
-   [Status](https://status.leakwatch.net)

© 2026 LeakWatch

[GitHub](https://github.com/Leakwatch-Scan)[X](https://x.com/LeakwatchScan)
