Auth0 Error "Service not enabled within domain"

Overview

A whitespace character in the audience identifier or the token request causes a service not enabled error during a client credentials exchange in Auth0. Recreating the API with the correct identifier or removing the whitespace from the request resolves the issue. When an attempt is made to retrieve an Access Token through a client credentials exchange, Auth0 generates the following error:

 

Service not enabled within domain: "API_IDENTIFIER"


Applies To

  • Auth0
  • Machine-to-Machine (M2M) Application
  • Access Token

Cause

When creating the Resource Server (API) in Auth0, the audience that was sent had a blank space/whitespace in front of the identifier.

"body": {
    "name": "API NAME",
   "identifier": " https://auth0[.]example[.]com/",
    "signing_alg": "RS256"
  }

When a client credentials exchange is attempted, the audience is not recognized due to the extra space, hence the error.


NOTE: The same could happen if trying to make a client credentials exchange, and in the POST to the '/oauth/token' endpoint, a blank space/whitespace is inadvertently added in front of the audience. The same error will occur. 

Solution

How is the API identifier whitespace issue resolved?

Resolve the API identifier whitespace issue by creating a new API with the correct identifier and deleting the incorrect API.

  1. Create a new API with the correct identifier, ensuring no extra spaces are present.
  2. Delete the previous API that contains the whitespace in the identifier.

 

Remove the Whitespace From the Token Request

Resolve the token request whitespace issue by locating the POST request to the token endpoint and removing any leading or trailing whitespace from the audience parameter.

  1. Locate the POST request to the /oauth/token endpoint.
  2. Remove any leading or trailing whitespace from the audience parameter.
  3. Resend the client credentials exchange request.

Recommended content

No recommended content found...