# Use Auth0 to secure public api with 3rd party access

**URL:** <https://community.auth0.com/t/use-auth0-to-secure-public-api-with-3rd-party-access/123961>\
**Category:** Get Help\
**Tags:** user-password-management, user-management\
**Created:** [January 2, 2024, 8:01am UTC](https://community.auth0.com/t/use-auth0-to-secure-public-api-with-3rd-party-access/123961 "2024-01-02T08:01:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![trondhindenes](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/trondhindenes/32/6352_2.png) [@trondhindenes](https://community.auth0.com/u/trondhindenes)\
**Post date:** [January 2, 2024, 8:01am UTC](https://community.auth0.com/t/use-auth0-to-secure-public-api-with-3rd-party-access/123961/1 "2024-01-02T08:01:45Z")

</div>

Hi,  
We’re evaluating different solutions for allowing 3rd party access to one of our APIs and since we’re already using Auth0 M2M to protect all our internal api-to-api comms, I’m trying to figure out if we can use Auth0 for 3rd party access into our APIs as well.

Some requirements:

- Api keys should be “ready to use”, and not require jumping through hoops such as replacing id tokens for access tokens, manage token refresh, etc. We want customers to be able to just use an api key header and that’s it
- Api keys should be long-lived
- API keys will be used for accounting (billing) so it must be possible to identify the api-key used
- 1000 api keys during next 2 years (but needs to support more than that too)

I’m wondering if Auth0 has any documentation or use-case for this type of scenario?

---

<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 2, 2024, 5:32pm UTC](https://community.auth0.com/t/use-auth0-to-secure-public-api-with-3rd-party-access/123961/2 "2024-01-02T17:32:43Z")

</div>

Hi @trondhindenes ,

The use case you describe seems to be subject to M2M authorization.

> [@trondhindenes](#):
>
> Api keys should be “ready to use”, and not require jumping through hoops such as replacing id tokens for access tokens, manage token refresh, etc. We want customers to be able to just use an api key header and that’s it

A machine2machine application requests a bearer token intended for the API and your clients can access its resources by just sending a request with the Authorization header and a received Bearer token.

> [@trondhindenes](#):
>
> Api keys should be long-lived

Maximum value for [Token Expiration](https://auth0.com/docs/secure/tokens/access-tokens/update-access-token-lifetime) is 2,592,000 seconds (30 days).

> [@trondhindenes](#):
>
> API keys will be used for accounting (billing) so it must be possible to identify the api-key used

There are monthly reports of the subscription usage - [Monitor Subscription Usage](https://auth0.com/docs/troubleshoot/customer-support/manage-subscriptions/monitor-subscription-usage)

> [@trondhindenes](#):
>
> - 1000 api keys during next 2 years (but needs to support more than that too)

The pricing page shows the monthly limits (please uncover the “Compare plans” tab) - [Pricing - Auth0](https://auth0.com/pricing)

> [@trondhindenes](#):
>
> I’m wondering if Auth0 has any documentation or use-case for this type of scenario?

One known challenge with this approach is that currently there’s no built-in mechanism to control how often your customers request a new access token for the API. There is a product feature request and you are welcome to upvote. It’s here: [Add rate limiting and cache for m2m token authentication endpoints](https://community.auth0.com/t/add-rate-limiting-and-cache-for-m2m-token-authentication-endpoints/75367)

There’s also a guidance developed by our developers to help with that (it’s downloadable and can be found in this post) - [Limit Client requests on Machine to Machine flow - #2 by peter.fernandez](https://community.auth0.com/t/limit-client-requests-on-machine-to-machine-flow/104083/2)

Hope this helps and feel free to reach out with questions!

---

<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:** [January 16, 2024, 5:33pm UTC](https://community.auth0.com/t/use-auth0-to-secure-public-api-with-3rd-party-access/123961/3 "2024-01-16T17:33:26Z")

</div>

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