# Getting User Permissions During Login Action for Native or SPA

**URL:** <https://community.auth0.com/t/getting-user-permissions-during-login-action-for-native-or-spa/82588>\
**Category:** Get Help\
**Tags:** login\
**Created:** [April 28, 2022, 7:47pm UTC](https://community.auth0.com/t/getting-user-permissions-during-login-action-for-native-or-spa/82588 "2022-04-28T19:47:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan.moriarty](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ryan.moriarty/32/33314_2.png) [@ryan.moriarty](https://community.auth0.com/u/ryan.moriarty)\
**Post date:** [April 28, 2022, 7:47pm UTC](https://community.auth0.com/t/getting-user-permissions-during-login-action-for-native-or-spa/82588/1 "2022-04-28T19:47:33Z")

</div>

I’m trying to access user permissions during a post-login Action. After looking at several different topics, I have this.

```auto
exports.onExecutePostLogin = async (event, api) => {
...
  const ManagementClient = require('auth0@2.23.0').ManagementClient;

  const management = new ManagementClient({
    clientId: event.client.client_id,
    clientSecret: event.secrets.client_secret,
    domain: event.secrets.domain
  });

  const params = { id: event.user.user_id, page: 0, per_page: 50, include_totals: false };

  let userPermissions = await management.getUserPermissions(params);
...

```

I am getting an “accessDenied” error on the call to getUserPermissions. After some more poking around, I see indications that I need to go to the settings for the Auth0 Management API and grant the `read:users` permission to my application. The catch is, I’m trying to log in with a Native Application, not M2M, so I don’t have a way to grant that permission. Is there a way for a Native App or SPA to use the ManagementClient during a Login Action?

---

<div class="post-metadata">

**Author:** ![gparascandolo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gparascandolo/32/38788_2.png) [@gparascandolo](https://community.auth0.com/u/gparascandolo)\
**Post date:** [June 10, 2022, 4:54pm UTC](https://community.auth0.com/t/getting-user-permissions-during-login-action-for-native-or-spa/82588/2 "2022-06-10T16:54:24Z")

</div>

@ryan.moriarty Not sure if you have found the solution to your problem - but if you have not, you can create a separate M2M Application with the proper permissions outside of the Native & SPA apps, and then use the newly generated M2M app’s client\_id & client\_secret within the Auth0 Action.

Be aware that the Management API calls within the Action is subject to the rate limits of the tenant, so you should look into caching an access token on your end somehow.

More information can be found in this FAQ  
[https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947)

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [June 10, 2022, 5:53pm UTC](https://community.auth0.com/t/getting-user-permissions-during-login-action-for-native-or-spa/82588/3 "2022-06-10T17:53:14Z")

</div>

Thanks for sharing @gparascandolo 😄

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [June 25, 2022, 5:54pm UTC](https://community.auth0.com/t/getting-user-permissions-during-login-action-for-native-or-spa/82588/4 "2022-06-25T17:54:00Z")

</div>

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