How to - Azure APIM as a client to invoke Auth0 management APIs?

Hi All,

I want to use Azure APIM as a client to invoke Auth0 management APIs.

The workflow looks like this.

Client application calls APIM → APIM creates an Auth token and calls Auth0 management API → APIM returns response to the client application.

I was going through this documentation: Sorry it is not allowing me to paste a link but you can find this in the documentation under Integrations > Azure API Management and it states

Using Auth0 as an OAuth 2.0 server to authenticate users wanting access to an API managed by the Azure API Management service

But my usecase is to have APIM create an auth token and call the Auth0 mangement API and return a response.

Are there any instructions to achieve this?

HI @TechThiru,

Welcome to the Auth0 Community!

I understand what you are trying to achieve with creating an APIM calling the Auth0 Management API, which is indeed the reverse mechanism of the current integration detailed in this article - Integrate with Azure API Management.

This flow is fully supported by a recently added feature from Microsoft, the Azure APIM Credential Manager using the Generic OAuth 2.0 provider, since Auth0 is not yet listed as a primary provider, so unfortunately there is no current documentation on our side that would provide this type of guidance. In this scenario it would be beneficial to create a feature request both on Microsoft’s forum, but also here in Auth0, since others might be interested as well in supporting this use case.

Generic steps needed on Auth0’s side to allow the APIM service to request a token with the Client Credentials grant would include:

  • Create a M2M Application: In the Auth0 Dashboard, create a Machine to Machine (M2M) Application
  • Authorize Management API: Go to the application’s settings, click the APIs tab, and authorize the application to access the Auth0 Management API
  • Grant Scopes: Grant the application the specific scopes it needs (e.g., read:users, update:users).
  • Gather Credentials: Record the Client ID, Client Secret, Domain, and the Audience (the Management API Identifier).

Then I would suggest following Microsoft’s documentation, specifically the general process for setting up a custom OAuth 2.0 provider with the Client Credentials flow, described under this Microsoft page - Configure common credential providers in credential manager.

I hope this helps!
Best regards,
Remus

Hi Remus,

Thanks for the reply. I have the following questions.

While following the article titled “Integrate with Azure API Management” under Third-Party Customization > Integrations

Important - Let’s keep aside that my original use case is to use APIM as a facade to call Auth0 management APIs.

For the purpose of this discussion, let’s look closer what the article teaches - Using Auth0 as an OAuth 2.0 server to authenticate users wanting access to an API managed by the Azure API Management service

Typically, my backend services or APIs will be hosted on azure and not on Auth0. So why should i need these two steps below? is it not just enough for my client applications to retrieve an OAuth token from the Auth0 assuming that is my Identity provider and provide that access token to APIM while invoking the APIs hosted on APIM?

I see the below mentioned steps. Honestly, I don’t understand why these steps are needed.
**
Configure Auth0**

**Create an API
**
You’ll need to create an API in Auth0 to represent the API managed by the Azure API Management Service.

Create a Regular Web Application

You’ll need to create a Regular Web Application (RWA) in Auth0 to communicate with the OAuth 2.0authorization serverin Azure:
**
Create and enable a connection**

You’ll need to create a connection in Auth0 and enable it for your application:

enlighten me, Thx!

Hi @TechThiru,

For the purpose of “Authenticating users wanting access to an API managed by the Azure API Management service Using Auth0 as an OAuth 2.0 server”, let me try to clarify why these steps are needed

Step 1 (Create an API): Even though your backend code runs in Azure, you must define an API in Auth0 to act as the logical identifier. If you skip this, Auth0 will issue an opaque token that Azure APIM cannot read. By creating this API record, you force Auth0 to issue a JSON Web Token (JWT) containing the specific signature and audience claims that Azure requires to validate the request.

Step 2 (Create a Regular Web Application): This step is necessary specifically for the Azure Developer Portal that allows you to click “Try it out” on your API endpoints directly from the browser. Since the Azure Portal is a server-side web application, you must register a Regular Web Application in Auth0 to represent it. This gives the Azure Portal a Client ID and Client Secret so it can successfully log you in and generate the tokens needed to test your API.

Step 3 (Create a Connection): If this flow involves users logging in to get that token, you need a “Connection” enabled. This simply tells Auth0 where to check the credentials—whether that is an Auth0 internal database, a corporate directory (Active Directory), or a social provider like Google. Without this, there is no source of truth for the user’s identity. Otherwise, if this is just a M2M credentials exchange, this step can be skipped.

In other words, you are not building your applications in Auth0, but you are registering the resource (the API), the test client (the Regular Web App/Azure Portal), and the user store (the connection) so that the entire security lifecycle operates correctly between Auth0 and Azure.

I hope this brings more light to your case.
Thank you, and if you have further inquiries please let me know!

Thanks for taking the time to explain the article.

Coming back to configuring a credential manager in APIM to call the Auth0 management API.

Could you please help me with why I am getting this error while configuring a credential manger and while creating the connection?

I provided the client id and client secret while configuring the connection, and it gives me this error:

Error: Failed to exchange client credentials for token. Response code=Forbidden, Details: {“error”:“access_denied”,“error_description”:“No audience parameter was provided, and no default audience has been configured”}

Why should i provide an audience?
Can i skip providing the audience?
APIM does not have a field to provide the audience. it only has fields for client Id and client secret.

How can i get over this ?

thanks!

Hi @TechThiru,

You are more than welcome!

Unfortunately you can not skip the audience parameter, since it is detailed in the error description as well, and Auth0 requires the audience parameter to know exactly which API your application is trying to access.

Since you have mentioned that the audience can not be configured Azure APIM, as a workaround, my recommendation would be to configure your Auth0 Tenant to treat the Management API as the “Default Audience”. This tells Auth0: “If a client asks for a token but doesn’t specify an audience, assume they want the Management API.”

In order to configure this, you can go to your Auth0 Dashboard - Settings - General - API Authorization Settings and in the Default Audience field, paste your Management API identifier, which you can find from the Auth0 Dashboard - Applications - APIs (https://{your-tenant-domain}.region.auth0.com/api/v2/)

Thank you,
Remus