Update user using auth0 sdk

I am using auth0 sdk com.auth0:auth0:1.19.0

public void changePassword(String userId, String newPassword) {
AuthAPI auth = new AuthAPI(domain, managementClientId, managementClientSecret);

    // Get Management API token
    String managementToken = auth.requestToken("https://" + domain + "/api/v2/").execute().getAccessToken();
    ManagementAPI managementAPI = new ManagementAPI(domain, managementToken);

    // Change user password
    UsersEntity usersEntity = managementAPI.users();
    try {
        User user = usersEntity.update(userId, new User().setPassword(newPassword));
        System.out.println("Password changed successfully for user: " + user.getEmail());
    } catch (APIException e) {
        // Handle error
        System.err.println("Failed to change password: " + e.getMessage());
    }

with this code i am unable to change password
especially with this line
User user = usersEntity.update(userId, new User().setPassword(newPassword));

Hey there @tharunnath !

Any clues as to why this might be failing? Does your management API access token have the correct permissions?

I haven’t tested this code or tried to write my own using the SDK, but you can also do this outside of the SDK using vanilla code.