Managementclient get groups

I am using auth0’s ManagementClient to query various things about the user. Can I use it to query and update group information? Groups are in the Authorization extension.

More specifically, what would be the easiest way to update groups for a new user? The way I think it can be done is very awkward:

  • Get all groups (to get the group IDs).
  • Match these with the groups the logged in user is in.
  • Assign the new user to the groups.

Thanks in advance for any advice.

Some more information: When adding a user, I am adding the groups (and roles) to app_metadata, which works fine, until the user logs in. When the user logs in, the app_metadata gets wiped out, because I haven’t actually updated the groups and roles.

I say this, because perhaps the right way to go about this is to create a rule to update groups and roles based on the app_metadata? This seems backwards to me.