Creating a User via the Management API Results in a HTTP 400 Error
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'.
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.
- Create User
- Connection
- Management API
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.
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):
- Login to the Auth0 dashboard as a tenant member (Administrator).
- Navigate Applications > Applications.
- 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"
Map an Application to a Connection
The next step is to associate the application with the desired connection.
- Login to the Auth0 dashboard.
- Navigate Authentication > Database > <connection-name> > Applications [ select from the menu ].
- 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.
- 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.