I’m getting rate limited on the endpoint POST /2/oauth2/token, I’m receiving this error in the response:
{ error: "rate_limited", error_description: "The request has been rate limited" }

But there is no mention of such rate limits in the documentation.

What should I do?

How many times are you calling the endpoint roughly?

150 times per minutes roughly

This endpoint is for obtaining an an app-only OAuth 2.0 Bearer Token - which does not expire, so you can generate it once, and persist it and reuse it - there is no need to regenerate it per request or anything.

We are not regenerating it per request, we just have a bunch of new users everyday. We are using the PKCE flow, which means that the access tokens of our users are only valid for 2 hour, after that we need to use the refresh token to get a new accessToken

1 Like

Ah, right Step 3 in PKCE right? OAuth 2.0 Making requests on behalf of users | Docs | Twitter Developer Platform ? Are you also making POST calls to /2/oauth2/token for refresh tokens too? Maybe it’s tripping up a rate limit if you’re hitting this endpoint multiple times in too short of a space of time, and you could spread out the refresh token calls more so that the new logins don’t fail? That’s the only thing that comes to mind right now.

But how are we supposed to scale our application if there is a rate limit on that?

I’m not twitter so i’ve no idea what the exact rate limit is (clearly there is one) the best i can suggest is maybe have a queue to throttle signups by a few seconds to spread out the calls, and maybe some trial and error to get it to whatever limit exists there.

Ok thanks for your help, I can’t find anywhere were we can contact the support directly. Don’t they have an email or something?

The only place is here, and maybe Platform form.

I wonder if filling out the Elevated POST limits form is the right one here? It’s usually for elevated POST limits for posting tweets etc, but technically this is POST limits too? Someone from twitter may have to clarify that.

Thank you so much for you help :slight_smile: , I will fill out the form and see whats happen

1 Like

Hi @ldemesla, I’ve reached out to the team to confirm the rate limit and see if there are any escalation pathways. I’ll let you know what I find out.

Thank you, it’s really hurting our platform since It relies a lot on the Twitter Oauth2

I confirmed the rate limit is 100 requests per 30 mins at the user level, but unfortunately, we do not have an elevation pathway. I passed this onto the team to consider for the future.

1 Like

I’m not exceeding a rate limit at the user level, it’s global to my app. Users that have never linked their Twitter account are getting rate limited.

Is there a global rate limit per app? How can it be increased?

Hey @eli possible to have some help there?