# Auth0Client for M2M?

**URL:** <https://community.auth0.com/t/auth0client-for-m2m/131875>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [April 12, 2024, 2:00pm UTC](https://community.auth0.com/t/auth0client-for-m2m/131875 "2024-04-12T14:00:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tjones](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tjones/32/48666_2.png) [@tjones](https://community.auth0.com/u/tjones)\
**Post date:** [April 12, 2024, 2:00pm UTC](https://community.auth0.com/t/auth0client-for-m2m/131875/1 "2024-04-12T14:00:17Z")

</div>

Hey there, is it possible to use Auth0Client for M2M communication? I can happily implement the POST example [here](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow/call-your-api-using-the-client-credentials-flow#example-post-to-token-url) to get an access token to call my API with but I’m planning on using this flow for applications external to my organization. I’d prefer to ask them to copy/paste a one-liner that instantiates Auth0Client to retrieve an access token rather than having them construct their own POST request.

When I try to instantiate Auth0Client with the app’s credentials I get

```auto
{"error":"access_denied","error_description":"Client is not authorized to access \\"https://...". You need to create a \\"client-grant\\" associated to this API. See: https://auth0.com/docs/api/v2#!/Client_Grants/post_client_grants"} (Auth0::AccessDenied)

```

---

<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:** [April 12, 2024, 9:54pm UTC](https://community.auth0.com/t/auth0client-for-m2m/131875/3 "2024-04-12T21:54:28Z")

</div>

Hey there @tjones welcome to the community!

I assume you’re referring to [Auth0Client](https://auth0.github.io/auth0-spa-js/classes/Auth0Client.html) of of `auth0-spa-js`? This is a client-side SDK not intended to handle client credentials of any kind (see [public vs confidential applications](https://auth0.com/docs/get-started/applications/confidential-and-public-applications)). A client credentials exchange should take place server-side and you can go about writing that code however you like.

More info here:

[https://community.auth0.com/t/auth0-support-for-api-keys-and-personal-access-tokens/98175](https://community.auth0.com/t/auth0-support-for-api-keys-and-personal-access-tokens/98175)

---

<div class="post-metadata">

**Author:** ![tjones](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tjones/32/48666_2.png) [@tjones](https://community.auth0.com/u/tjones)\
**Post date:** [April 15, 2024, 11:49am UTC](https://community.auth0.com/t/auth0client-for-m2m/131875/4 "2024-04-15T11:49:24Z")

</div>

Sorry, I should have been more specific. I was referring to the ruby-auth0 client. I’m assuming the response still applies?

---

<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:** [April 22, 2024, 8:07pm UTC](https://community.auth0.com/t/auth0client-for-m2m/131875/5 "2024-04-22T20:07:17Z")

</div>

Gotcha, thanks for clarifying and sorry just getting back to you on this!

Management API SDK libraries including`ruby-auth0` are designed to be used against the Auth0 Management API as opposed to your own - It doesn’t sound like that’s suitable for your use case.

---

<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:** [May 6, 2024, 8:07pm UTC](https://community.auth0.com/t/auth0client-for-m2m/131875/6 "2024-05-06T20:07:55Z")

</div>

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