Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update username Or password using management API #46

Closed
shoikot opened this issue Mar 15, 2017 · 2 comments
Closed

Update username Or password using management API #46

shoikot opened this issue Mar 15, 2017 · 2 comments

Comments

@shoikot
Copy link

shoikot commented Mar 15, 2017

I'm trying to update a existing Users' username and password with this method https://github.com/auth0/auth0-java#update

But getting a APIException and the exception description says:

Additional properties not allowed: identities,updated_at,created_at,family_name,given_name,nickname,name,picture,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)

I've followed this thread : https://auth0.com/forum/t/apiv2-payload-validation-error/372/4 , where someone named 'yenkel' said

"I'll track this so we can add support to modify this fields in the near future, only for users that have been created in a database connection (not from any other IdP)."

that thread is old , did they implemented it , please let me know
Question: how can I update a the username and password of existing user profile, Or how can I update that user profile ?

Thanks in advance :)

@lbalmaceda
Copy link
Contributor

Hi @shoikot,
In the same post you've linked says they removed the edition of those fields at the root level of the profile. The current way to add custom fields as of Management API v2 is to save values in user_metadata using the PATCH /v2/users. With this same method you can update the username and password values if you like. Keep in mind that username and password cannot be both updated in the same call. Check that your code looks similar to this:

        User updatedUser = new User("your-db-connection");
        //update either the password
        //updatedUser.setPassword("new-password");
        //or the username
        //updatedUser.setUsername("new-username");
        Map<String, Object> userMetadata = new HashMap<>();
        userMetadata.put("age", "35");
        //add more fields
        updatedUser.setUserMetadata(userMetadata);

        ManagementAPI mgmtAPI = new ManagementAPI("domain.auth0.com", "the-api-token");
        mgmtAPI.users().update("the-user-id", updatedUser).execute();

@shoikot
Copy link
Author

shoikot commented Mar 16, 2017

@lbalmaceda thanks , it worked :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants