Creating a User via the Management API Results in a HTTP 400 Error

Overview

An attempt to create a user via the Management API for the target connection ( in this case 'demo-dB' ) will throw an error of the general form:

Request failed with status code 400: connection is disabled

However, attempts to use the Management API to create users on other Auth0 username-password connections may well succeed without error. 

 

As part of the user creation process, a new user instance is created via the Auth0 Management API, using the Create-a-User call to the "POST /api/v2/users" endpoint. In this example, it is intended that the new user instance be created in an Auth0  username-password database connection called 'demo-dB'.

Screenshot 2024-02-02 at 10.43.39.png

However, the call fails and the following error is displayed:

2023-02-03T12:21:39.784364757Z: [INFO] com.auth0.exception.APIException: Request failed with status code 400: connection is disabled (client_id: XXXalcyGabcGGln6GXRuIK1Nbh4tXYYY - connection: demo-dB )

In this instance:

  • 'demo-dB' is a regular Auth0 username-password database connection within a tenant
  • 'client_id' is a reference to the client application that the user attempted to signup for

This error occurs even though the connection is enabled for an organisation, and creating a user via the Auth0 dashboard works as expected.

Applies To
  • Create User
  • Connection
  • Management API
Cause

The sign-up attempt failed because the client application for which the user wanted to sign up does not have an association with the desired Auth0 username-password database connection.

Solution

Identify the Client Application

In order to solve this problem, first identify the application that is mentioned in the error message. In this example, the client_id is "XXXalcyGabcGGln6GXRuIK1Nbh4tXYYY".

If the number of applications configured within the tenant is relatively small (less than 200):

  1. Login to the Auth0 dashboard as a tenant member (Administrator).
  2. Navigate Applications > Applications.
  3. Search for the client_id within the web page ( typically, this is CTRL+F for Windows or Command+F for Mac ).

If a large number of applications are configured in the tenant, it is more efficient to use the Management API and make a call to the Get-a-Client endpoint ( "GET  /api/v2/clients/{id} " ).  For example, the settings shown in the graphic below will retrieve the application name that corresponds to the client_id of"XXXalcyGabcGGln6GXRuIK1Nbh4tXYYY"

Screenshot 2024-02-02 at 11.54.51.png


Map an Application to a Connection

The next step is to associate the application with the desired connection. 

  1. Login to the Auth0 dashboard.
  2. Navigate Authentication > Database > <connection-name> > Applications [ select from the menu ].
  3. Toggle the green slider next to the application name to enable access to the connection. The following graphic gives an example of what this might look like. 

Associate Applications with a Database Connection
  1. Now try to signup a user from within the application. After making this adjustment, there should be no error.

Attempting to create a user via the Management API should now also work.

Related References

Recommended content

No recommended content found...