App still using default DB to sign in

Ready to post? :mag: First, try searching for your answer.
I have two applications within my Tenant. For one of the applications it’s using the default Username-Password-Authentication db, and the other is using a second DB I created, at least that is the intention. When I call the oath/token endpoint with the password grant type, I get an error saying that the application is not set up with the Username-Password-Authentication database. I tried specifying the “realm” in the request body as well as the connection in the request body to the new DB’s name but with no success. Any ideas what I am missing and why it is still trying to use the default database to perform the login?

Hi @jfurnish2

Welcome to the Auth0 Community!

By default, if an application has multiple Databases enabled, Auth0 will use the user/password database connection, so unless it’s necessary to have both of them, a simple fix would be to disable the second DB from the Application.

Considering you do need both DBs enabled, you will then need to specify a criteria based on which Auth0 will authenticate the user either via one DB or the other. As you’ve mentioned using the /oauth/token endpoint with password grant type, I suspect the issue might be that you need to specify the grant_type as password-realm instead of password, like in the below example :

{
      "grant_type": "http://auth0.com/oauth/grant-type/password-realm",
      "client_id": "123",
      "username": "alice",
      "password": "A3ddj3w",
      "realm": "my-database-connection",
      "scope": "openid email offline_access",
      "audience": "https://api.example.com"
    }

More information on this can be found in our documentation here and in this other Community post.

Hope this helped!
Gerald

1 Like

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