# Accessing Auth0 Management API in rules vs hooks

**URL:** <https://community.auth0.com/t/accessing-auth0-management-api-in-rules-vs-hooks/19264>\
**Category:** Get Help\
**Tags:** rules, hooks, management-api\
**Created:** [December 19, 2018, 9:33pm UTC](https://community.auth0.com/t/accessing-auth0-management-api-in-rules-vs-hooks/19264 "2018-12-19T21:33:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric.jutrzenka](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/eric.jutrzenka/32/9959_2.png) [@eric.jutrzenka](https://community.auth0.com/u/eric.jutrzenka)\
**Post date:** [December 19, 2018, 9:33pm UTC](https://community.auth0.com/t/accessing-auth0-management-api-in-rules-vs-hooks/19264/1 "2018-12-19T21:33:00Z")

</div>

We’re looking at using some of the extension points in auth0. One thing we’d like to do is update the user’s email after authentication where the email is the user name. The steps we’re trying to implement are:

1. User requests to change email
2. New email is stored in user\_metadata
3. User is directed to hosted page authenticate with current credentials
4. On successful authentication either a rule or a hook fires to update the users email address with the value stored in their metadata and set email\_verified to false.

The reason we like this is because:

- we want the user to auth before changing their email to prevent an attacker using an existing session to change the email
- we want the auth to happen via universal login/hosted page
- we want to minimize any sharing of our auth0 secrets.

As far as I can tell we can do this via rules or hooks and hooks are the new way to extend auth0.

It looks like it’s fairly easy to access the Management API in a rule with the required scope to update the users email here as described here:

> **[Use the Management API from within Rules - Auth0 Docs](https://auth0.com/docs/customize/rules/use-management-api)**
>
> Call the Auth0 Management API from within a Rule using the restricted auth0 ManagementClient object, or require a newer node-auth0 version for additional endpoints and scopes.

This is because rules runtime provides an access token with the right scopes to do this. And the great thing is, we don’t have to share our secrets with anything to do so.

Can we do a similar thing with hooks?

---

<div class="post-metadata">

**Author:** ![nicolas\_sabena](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicolas_sabena/32/6064_2.png) [@nicolas\_sabena](https://community.auth0.com/u/nicolas_sabena)\
**Post date:** [December 21, 2018, 1:33pm UTC](https://community.auth0.com/t/accessing-auth0-management-api-in-rules-vs-hooks/19264/2 "2018-12-21T13:33:55Z")

</div>

Hi @eric.jutrzenka. Unfortunately, hooks don’t have this feature. I encourage you to describe this as a feature request in [Auth0: Secure access for everyone. But not just anyone.](https://auth0.com/feedback) to be analyzed by the Product team.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [August 28, 2019, 2:54pm UTC](https://community.auth0.com/t/accessing-auth0-management-api-in-rules-vs-hooks/19264/3 "2019-08-28T14:54:12Z")

</div>


