# How to use M2M token scopes

**URL:** <https://community.auth0.com/t/how-to-use-m2m-token-scopes/139264>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [July 18, 2024, 7:26pm UTC](https://community.auth0.com/t/how-to-use-m2m-token-scopes/139264 "2024-07-18T19:26:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![richardb](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@richardb](https://community.auth0.com/u/richardb)\
**Post date:** [July 18, 2024, 7:26pm UTC](https://community.auth0.com/t/how-to-use-m2m-token-scopes/139264/1 "2024-07-18T19:26:48Z")

</div>

Hello,

I am a little confused as to how we would use scopes present in an M2M token to deny or allow access, since all the scopes allowed for the app are always returned. Does this mean we have to create a new app for every different set of scopes we want to allow?

Thank you!

---

<div class="post-metadata">

**Author:** ![richardb](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@richardb](https://community.auth0.com/u/richardb)\
**Post date:** [July 19, 2024, 2:41pm UTC](https://community.auth0.com/t/how-to-use-m2m-token-scopes/139264/4 "2024-07-19T14:41:53Z")

</div>

would you know how to do it with actions? In the documentation it says there is a function called api.accessToken.removescope(), but in the m2m flow, auth0 does not recognize it.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [July 19, 2024, 4:11pm UTC](https://community.auth0.com/t/how-to-use-m2m-token-scopes/139264/5 "2024-07-19T16:11:59Z")

</div>

Hi @richardb,

Yes, that’s correct 👍 . You would need to create a new M2M application and grant it specific scopes (permissions) from your API.

Let me know if you have any additional questions.

Cheers,  
Rueben

---

<div class="post-metadata">

**Author:** ![richardb](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@richardb](https://community.auth0.com/u/richardb)\
**Post date:** [July 19, 2024, 5:01pm UTC](https://community.auth0.com/t/how-to-use-m2m-token-scopes/139264/6 "2024-07-19T17:01:09Z")

</div>

Is that the best way to do it? Seems like there should be a more automatic way of doing things, instead of manually creating a new app for every group of services and assigning them different scopes

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [July 19, 2024, 5:50pm UTC](https://community.auth0.com/t/how-to-use-m2m-token-scopes/139264/7 "2024-07-19T17:50:13Z")

</div>

Hi @richardb,

Yes, it would be the best way to do it. Let me clarify: you won’t be able to use `api.accessToken.removescope()` as that’s intended for the authorization code flow, which involves user interaction.

In a client credentials flow (Machine-to-Machine), when the m2m app authorizes against the API, it gets all the permissions defined for that application.

By doing so, you can control the permissions by setting specific scopes for each m2m app.

---

<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:** [August 2, 2024, 5:50pm UTC](https://community.auth0.com/t/how-to-use-m2m-token-scopes/139264/8 "2024-08-02T17:50:37Z")

</div>

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