Auth0 User Update Error

You may get the following error when you use Auth0 management API to update a user:

Payload validation error: 'Additional properties not allowed: locale,logins_count,last_login,last_ip, identities,updated_at,created_at,user_id (consider storing them in app_metadata or user_metadata. See "Users Metadata" in https://auth0.com/docs/api/v2/changes for more details)'.


To fix this, you need provide a new instance of the user object that should be created by using public constructor with no arguments to the Auth0 management API update method:


AuthAPI authAPI = new AuthAPI("domain", "clientId", "clientSecret");
authRequest = authAPI.requestToken(apiAudience);
TokenHolder holder = authRequest.execute();
ManagementAPI managementAPI = new ManagementAPI(domain, holder.getAccessToken());

User user = new User();
user.setUserMetadata(userMetadata);
user.setAppMetadata(userAppMetadata);

managementAPI.updateUserMetadataByUserId("auth0UserId", user);