# Auth0 Rate Limit /oauth/token endpoint - Custom actions or Hooks

**URL:** <https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372>\
**Category:** Get Help\
**Tags:** clients, management-api\
**Created:** [April 10, 2023, 8:48am UTC](https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372 "2023-04-10T08:48:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudeesh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sudeesh/32/33671_2.png) [@sudeesh](https://community.auth0.com/u/sudeesh)\
**Post date:** [April 10, 2023, 8:48am UTC](https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372/1 "2023-04-10T08:48:25Z")

</div>

Hi Team,  
We would like to have a custom action or hook to handle the number of token requests that is sent to Auth0. We dont want the other customers to be impacted because of one customer sending multiple requests to the token endpoint.

Any leads which i can look into ?

Can we use custom actions / hooks ? If yes, please help with some sample.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 10, 2023, 7:48pm UTC](https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372/3 "2023-04-10T19:48:30Z")

</div>

Hi @sudeesh,

Welcome back to the Auth0 Community!

A post login Action would be running _after_ a successful authentication takes place. This means it wouldn’t necessarily prevent requests to the token endpoint. Are you running into a scenario where a single user is causing rate limit errors for your whole tenant?

This may fall under [Attack Protection](https://auth0.com/docs/secure/attack-protection).

---

<div class="post-metadata">

**Author:** ![sudeesh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sudeesh/32/33671_2.png) [@sudeesh](https://community.auth0.com/u/sudeesh)\
**Post date:** [April 11, 2023, 3:43am UTC](https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372/4 "2023-04-11T03:43:45Z")

</div>

Hi @dan.woda,  
Thanks for the details. It the client credentials token which we would like to limit before it hits the rate limit of auth0.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 11, 2023, 1:40pm UTC](https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372/5 "2023-04-11T13:40:12Z")

</div>

Are you concerned with the user hitting the [Rate Limit Policy](https://auth0.com/docs/troubleshoot/customer-support/operational-policies/rate-limit-policy) or the user using up your Token Quota?

---

<div class="post-metadata">

**Author:** ![sudeesh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sudeesh/32/33671_2.png) [@sudeesh](https://community.auth0.com/u/sudeesh)\
**Post date:** [April 12, 2023, 3:21am UTC](https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372/6 "2023-04-12T03:21:38Z")

</div>

In case, if one user is hitting the token endpoint continuously and if that reaches the rate limit, it will affect the other users also. So we want to have a limit set for a user to use the token generation endpoint with some limits.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 12, 2023, 1:05pm UTC](https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372/7 "2023-04-12T13:05:08Z")

</div>

Thanks for the added info.

The client should be caching tokens, and requesting +30 tokens/second in a single client would be quite unusual. You could simply revoke their credentials, have you considered this?

---

<div class="post-metadata">

**Author:** ![sudeesh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sudeesh/32/33671_2.png) [@sudeesh](https://community.auth0.com/u/sudeesh)\
**Post date:** [April 12, 2023, 3:00pm UTC](https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372/8 "2023-04-12T15:00:08Z")

</div>

When there are multiple such clients, thats where we were thinking of having a way to reject or return 429 through custom action or hooks.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 12, 2023, 5:14pm UTC](https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372/9 "2023-04-12T17:14:22Z")

</div>

You can deny requests from M2M clients with the [Machine to Machine Flow](https://auth0.com/docs/customize/actions/flows-and-triggers/machine-to-machine-flow) Action trigger.

This won’t necessarily prevent requests but will allow you to deny successful requests.

---

<div class="post-metadata">

**Author:** ![sudeesh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sudeesh/32/33671_2.png) [@sudeesh](https://community.auth0.com/u/sudeesh)\
**Post date:** [May 2, 2023, 11:48am UTC](https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372/10 "2023-05-02T11:48:51Z")

</div>

So If we deny the request, will it count for the Rate Limit ?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 21, 2023, 6:38pm UTC](https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372/12 "2023-06-21T18:38:11Z")

</div>

Apologies for the delay.

I reached out to the team on that question and found that incoming requests are counted before they are deemed successful or not.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [July 5, 2023, 6:38pm UTC](https://community.auth0.com/t/auth0-rate-limit-oauth-token-endpoint-custom-actions-or-hooks/104372/13 "2023-07-05T18:38:16Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
