# Protected API request from actions

**URL:** <https://community.auth0.com/t/protected-api-request-from-actions/79499>\
**Category:** Get Help\
**Tags:** m2m, auth, actions\
**Created:** [March 8, 2022, 1:39pm UTC](https://community.auth0.com/t/protected-api-request-from-actions/79499 "2022-03-08T13:39:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luka1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/luka1/32/26455_2.png) [@luka1](https://community.auth0.com/u/luka1)\
**Post date:** [March 8, 2022, 1:39pm UTC](https://community.auth0.com/t/protected-api-request-from-actions/79499/1 "2022-03-08T13:39:21Z")

</div>

Hello,

I would like to call a protected API from my actions. I was thinking of using M2M flow, but that means that I’d have to do client credential exchange every time action is triggered - which is a bit excessive IMO and also M2M is limited to 1000 authentication. What do you prefer I do in this case? I’d like to protect the API called from the action for obvious reasons (to prevent spam) Is there any way of generating long lived token that I can just put inside the secret?

Thanks

Thanks!

---

<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:** [March 10, 2022, 6:42pm UTC](https://community.auth0.com/t/protected-api-request-from-actions/79499/3 "2022-03-10T18:42:04Z")

</div>

Hi @luka1,

Yes, you can use the M2M flow. This would be the OAuth way of doing it, but there is no caching mechanism available in Actions at the moment.

You could also make your own secret or API key, use basic auth, etc.

---

<div class="post-metadata">

**Author:** ![luka1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/luka1/32/26455_2.png) [@luka1](https://community.auth0.com/u/luka1)\
**Post date:** [March 21, 2022, 9:44am UTC](https://community.auth0.com/t/protected-api-request-from-actions/79499/4 "2022-03-21T09:44:53Z")

</div>

Thanks! Decided to use the JWT sign feature, so i’m just signing payloads with a key that only backend knows.

---

<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:** [March 21, 2022, 5:22pm UTC](https://community.auth0.com/t/protected-api-request-from-actions/79499/5 "2022-03-21T17:22:06Z")

</div>

Sounds good. Thanks for the update!

---

<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:** [April 5, 2022, 5:22pm UTC](https://community.auth0.com/t/protected-api-request-from-actions/79499/6 "2022-04-05T17:22:33Z")

</div>

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