Overview
When calling api.accessToken.addScope
inside an action, the following error occurs:
“api.accessToken.addScope is not a function”
Applies To
- Actions
- Post-login trigger
- api.accessToken.addScope
Cause
api.accessToken.addScope
is only available in v3 of the post-login trigger. This error will occur if using v2.
Solution
Patch the action’s supported triggers) to use v3 of post-login instead of v2 using the following payload:
{
"supported_triggers": [
{
"id": "post-login",
"version": "v3"
}
]
}
Example with curl:
$ curl -L -X PATCH 'https://<auth0 domain>/api/v2/actions/actions/<action id>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <management API token>' \
-d '{"supported_triggers":[{"id":"post-login","version":"v3"}]}'
Once patched, re-deploy the action, and the function should be available as expected.