Unable to login with password using Auth0-java

I’m trying to login users with password using Auth0-java using a machine to machine application. I followed “Log In with Password - /oauth/token” from “https://github.com/auth0/Auth0-java”. Here is the snippet of code:

    AuthAPI auth = new AuthAPI("{MY-ACCOUNT}.auth0.com",

    AuthRequest request = auth.login(email, password)
        .setScope("openid contacts");

        TokenHolder holder = request.execute();

I get the following exception:

com.auth0.exception.APIException: Request failed with status code 400: invalid audience specified for password grant exchange

I’m not sure what the audience is supposed to be. In the example on the library’s doc is “https://api.me.auth0.com/users”. Any ideas what could be wrong ?


Welcome to the Community!

It sounds like there may be some misunderstandings here. A machine to machine connection inherently has no users. It should not include a username/email and password. That may be configured incorrectly in the dashboard.

The audience parameter is the intended audience of the token, typically a custom api that you are trying to secure, or an auth0 API like the /userinfo endpoint. You can find the the identifier will be set when you register your API.

Does this help?

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