# Machine-to-Machine Access Token through Actions

**URL:** <https://community.auth0.com/t/machine-to-machine-access-token-through-actions/100947>\
**Category:** Get Help\
**Tags:** actions-management-api, management-api\
**Created:** [February 21, 2023, 3:56pm UTC](https://community.auth0.com/t/machine-to-machine-access-token-through-actions/100947 "2023-02-21T15:56:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saiful1991](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@saiful1991](https://community.auth0.com/u/saiful1991)\
**Post date:** [February 21, 2023, 3:56pm UTC](https://community.auth0.com/t/machine-to-machine-access-token-through-actions/100947/1 "2023-02-21T15:56:32Z")

</div>

Hello,

I would like to ask about a business use-case where user/client requests for a Machine-to-Machine access token through Actions. Client will request a m2m access token and an Action would decide if it will return either a cached token or a newly generated token. it would be something like this:

```auto
Client -> Token Requested -> Action (If available return cached token, else create a new token and return) -> Token Issued -> Client

```

Based on this use-case I have following questions:

1. Is this a supported scenario using Actions?
2. If it is not, is this feature already there in the roadmap?
3. Is there any recommendation to implement this outside of auth0?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [February 22, 2023, 3:08am UTC](https://community.auth0.com/t/machine-to-machine-access-token-through-actions/100947/3 "2023-02-22T03:08:55Z")

</div>

Hi there @saiful1991!

I believe this may be exactly what you are looking for:

[https://community.auth0.com/t/caching-management-api-access-tokens-in-login-action/95855](https://community.auth0.com/t/caching-management-api-access-tokens-in-login-action/95855)

I will say that my colleague tested this recently and ran into some issues with the size of the cached value - His findings may prove useful as well:

> [@Caching M2M access token in Actions](https://community.auth0.com/t/caching-m2m-access-token-in-actions/100734/4):
>
> Hi @saiful1991, Thank you for your patience. After carefully going through our [Action Limitations](https://auth0.com/docs/customize/actions/limitations#:~:text=The%20cumulative%20size%20of%20cached%20keys%20and%20their%20values%20must%20not%20exceed%208192%20bytes) documentation, I noticed that it makes note that the cumulative size of cached keys and their values must not exceed 8192 bytes. Given that, one way to make this work is to use a few cache (key, value) pairs to store the Management API Token. Because Cache Keys are limited to 2048 bytes, we can make this work with 3 Cache items. I have tested this myself and got it to work with the following: …

Hope this helps!

---

<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:** [March 8, 2023, 3:08am UTC](https://community.auth0.com/t/machine-to-machine-access-token-through-actions/100947/4 "2023-03-08T03:08:59Z")

</div>

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