# Any guidance on regular web app crdentials correct usage to access Management API?

**URL:** <https://community.auth0.com/t/any-guidance-on-regular-web-app-crdentials-correct-usage-to-access-management-api/125931>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [January 29, 2024, 11:09am UTC](https://community.auth0.com/t/any-guidance-on-regular-web-app-crdentials-correct-usage-to-access-management-api/125931 "2024-01-29T11:09:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![h825](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/h825/32/54360_2.png) [@h825](https://community.auth0.com/u/h825)\
**Post date:** [January 29, 2024, 11:09am UTC](https://community.auth0.com/t/any-guidance-on-regular-web-app-crdentials-correct-usage-to-access-management-api/125931/1 "2024-01-29T11:09:52Z")

</div>

Working on Remix app that reuses Management API client defined like this (to update user / metadata):

```auto
import { ManagementClient } from 'auth0';

const management = new ManagementClient({
    domain: getOrThrow("AUTH0_DOMAIN"),
    clientId: getOrThrow("AUTH0_CLIENT_ID"),
    clientSecret: getOrThrow("AUTH0_CLIENT_SECRET"),
});

...

return await management.users.update({ id: userId }, filteredUpdate);

```

It doesn’t work with message:

```auto
AuthApiError: Client is not authorized to access "https://MY_AUTH0_DOMAIN.au.auth0.com/api/v2/". You need to create a "client-grant" associated to this API. See: https://auth0.com/docs/api/v2#!/Client_Grants/post_client_grants

```

Ok, reading article and trying to create grants exactly as described in the documentation:

```auto
curl -L 'https://login.auth0.com/api/v2/client-grants' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
    "client_id":"MY_CLIENT_ID",
    "audience":"https://MY_APP_DOMAIN.au.auth0.com/api/v2/",
    "scope":["create:client_grants"]
}'

```

and it fails with error

```auto
{"statusCode":401,"error":"Unauthorized","message":"Missing authentication"}

```

It seems like either I missing something or documentation is incomplete, but I cannot get what to fix.

All the credentials are used on the server side and never leaking to the client.

Please assist!

---

<div class="post-metadata">

**Author:** ![marcelina.barycka](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marcelina.barycka/32/56162_2.png) [@marcelina.barycka](https://community.auth0.com/u/marcelina.barycka)\
**Post date:** [January 29, 2024, 3:05pm UTC](https://community.auth0.com/t/any-guidance-on-regular-web-app-crdentials-correct-usage-to-access-management-api/125931/2 "2024-01-29T15:05:09Z")

</div>

Hey there @h825 ,

Your Management API Client has to be added to your Auth0 tenant as an M2M application. This M2M application has to be Authorized for the Management API along with relevant permissions, like update:users (you can do all this via Auth0 dashboard):

 ![image](https://global.discourse-cdn.com/auth0/original/3X/c/c/cc7432c85b1a274b515202350fbf705af2245c4e.png)

In your case I believe you are missing the last part - permissions.

Please let us now how it goes!

> **[Using Machine to Machine (M2M) Authorization](https://auth0.com/blog/using-m2m-authorization/)**
>
> How to set up non-interactive apps using the client credentials grant and Auth0 to perform IoT device, CLI tool, and more machine to mach...

---

<div class="post-metadata">

**Author:** ![h825](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/h825/32/54360_2.png) [@h825](https://community.auth0.com/u/h825)\
**Post date:** [January 29, 2024, 7:33pm UTC](https://community.auth0.com/t/any-guidance-on-regular-web-app-crdentials-correct-usage-to-access-management-api/125931/3 "2024-01-29T19:33:19Z")

</div>

Thank you @marcelina.barycka. I try to do that but could you please point me also to the docs section which describes WHY it works this way. I checked “flows” section and it seems legit to use client id/secret for actions like this. Now I cannot get full work cycle.

---

<div class="post-metadata">

**Author:** ![marcelina.barycka](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marcelina.barycka/32/56162_2.png) [@marcelina.barycka](https://community.auth0.com/u/marcelina.barycka)\
**Post date:** [January 30, 2024, 11:15am UTC](https://community.auth0.com/t/any-guidance-on-regular-web-app-crdentials-correct-usage-to-access-management-api/125931/4 "2024-01-30T11:15:54Z")

</div>

You’re welcome @h825 !

> [@h825](#):
>
> could you please point me also to the docs section which describes WHY it works this way. I checked “flows” section and it seems legit to use client id/secret for actions like this.

I believe you ask why in a backend service (like a regular web app) you still need to use the Management Api Client credentials and a linked to it M2M flow.

Any time you want to:

- [update user data](https://auth0.com/docs/api/management/v2/users/patch-users-by-id)
- perform administrative tasks to your Auth0 tenant

you use the M2M apps granted relevant for these tasks permissions.

In contrast, if your **backend service** integrate with Auth0 to perform **user’s authentication and authorization** , you use flows reserved to Regular Web Apps.

---

<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:** [February 13, 2024, 11:16am UTC](https://community.auth0.com/t/any-guidance-on-regular-web-app-crdentials-correct-usage-to-access-management-api/125931/5 "2024-02-13T11:16:19Z")

</div>

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