Auth0 Home Blog Docs

Can we send custom properties in the login request using the Java Library?

custom-property
token-endpoint
request

#1

Hello. We have a rule setup to check our login requests for a custom property named “x_client_id” that is passed in the request body to an /oauth/token call. However we are not able to add this property using the Java library from GitHub as there doesn’t seem to be a function to add custom properties to the auth.login(…) call. Everything works great using Postman.

POST /oauth/token
  {
        "grant_type": "http://auth0.com/oauth/grant-type/password-realm",
        "client_id": "xxx",
        "client_secret": "yyy",
        "username": "ggrissom@nasa.org",
        "password": "zzz",
        "scope": "openid profile offline_access",
        "realm": "Username-Password-Authentication",
        "audience": "https://xyz.auth0.com/userinfo",
        "x_client_id": "ANBC"
    }

Is there something that we aren’t seeing in the Java library? If not, is there any chance we could get something added in a newer version to do this? Maybe a function that accepts a Map of key/value pairs to add to the request body?


#2

Maybe this has something to do with properly using (custom claims)[https://auth0.com/docs/api-auth/tutorials/adoption/scope-custom-claims#custom-claims] to pass custom data in the token for OIDC compliant apps?


#3

No I’ve got the custom claims working perfectly. It’s more a limitation on the Java library. It would be handy if we could get another setter that took in a Map and would add the values in the map to the request. Maybe something like…

Map<String, Object> customProps = new HashMap<>();
customProps.put("x_client_id", "ABCD");

AuthRequest request = auth.login("me@domain.com", "password123", "Username-Password-Authentication")
        .setAudience("https://api.me.auth0.com/users")
        .setScope("openid contacts")
        .setCustomProperties(customProps);

#4