# api.accessToken.addScope is not a function when used from onExecuteCredentialsExchange action template

**URL:** <https://community.auth0.com/t/api-accesstoken-addscope-is-not-a-function-when-used-from-onexecutecredentialsexchange-action-template/147305>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [September 16, 2024, 4:43pm UTC](https://community.auth0.com/t/api-accesstoken-addscope-is-not-a-function-when-used-from-onexecutecredentialsexchange-action-template/147305 "2024-09-16T16:43:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jortiz-squaretrade](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jortiz-squaretrade/32/60520_2.png) [@jortiz-squaretrade](https://community.auth0.com/u/jortiz-squaretrade)\
**Post date:** [September 16, 2024, 4:43pm UTC](https://community.auth0.com/t/api-accesstoken-addscope-is-not-a-function-when-used-from-onexecutecredentialsexchange-action-template/147305/1 "2024-09-16T16:43:35Z")

</div>

Ready to post? 🔍 First, try searching for your answer.  
As part of rules/hooks migration to actions I have successfully migrated rules to actions but when dealing with hooks, I am facing issues updating scopes from actions when using the onExecuteCredentialsExchange action template due to:

api.accessToken.addScope is not a function

I’ll really appreciate if you could please let me know if there is a way of updating scopes from this m2m action using Credentials Exchange template

---

<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:** [September 16, 2024, 11:51pm UTC](https://community.auth0.com/t/api-accesstoken-addscope-is-not-a-function-when-used-from-onexecutecredentialsexchange-action-template/147305/4 "2024-09-16T23:51:45Z")

</div>



---

<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:** [September 17, 2024, 12:10am UTC](https://community.auth0.com/t/api-accesstoken-addscope-is-not-a-function-when-used-from-onexecutecredentialsexchange-action-template/147305/5 "2024-09-17T00:10:35Z")

</div>

Hi @jortiz-squaretrade,

Welcome to the Auth0 Community!

The `api.accessToken.addScope` function only exists for the post-login flow.

In the machine-to-machine flow, that function is unavailable.

Sadly, there is no way to update the scopes in a machine-to-machine action script. I found [this feedback request](https://community.auth0.com/t/m2m-action-is-not-able-to-modify-scope-or-permissions-claims/133888) asking for this feature. I recommend upvoting the feedback request so that it can be prioritized for implementation based on the highest votes.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![jortiz-squaretrade](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jortiz-squaretrade/32/60520_2.png) [@jortiz-squaretrade](https://community.auth0.com/u/jortiz-squaretrade)\
**Post date:** [September 17, 2024, 6:11am UTC](https://community.auth0.com/t/api-accesstoken-addscope-is-not-a-function-when-used-from-onexecutecredentialsexchange-action-template/147305/6 "2024-09-17T06:11:01Z")

</div>

Sad news 😞  
Any way, thank you very much @rueben.tiow for replying back

---

<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:** [September 17, 2024, 3:57pm UTC](https://community.auth0.com/t/api-accesstoken-addscope-is-not-a-function-when-used-from-onexecutecredentialsexchange-action-template/147305/7 "2024-09-17T15:57:14Z")

</div>



---

<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:** [October 1, 2024, 3:58pm UTC](https://community.auth0.com/t/api-accesstoken-addscope-is-not-a-function-when-used-from-onexecutecredentialsexchange-action-template/147305/8 "2024-10-01T15:58:03Z")

</div>

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