API:User group membership

Token
To change a user's group membership, a changerights token is required. This token is not equal to the edit token: it depends on the name of the user whose rights are being changed. A changerights token can be obtained as follows:

Groups you can add to and remove from
To verify which groups you're allowed to add a user to or remove them from, and which groups the user is already a member of, you can request a list of groups using the listgroups parameter. This is usually done together with requesting the changerights token:

From the above it can be gleaned that you can add users to the bot, sysop and bureaucrat groups, remove them from the bot, sysop and bureaucrat groups , and that Bob is currently in the bureaucrat group.

Adding users to and removing them from groups
Users can be added to groups or removed from them with action=changerights.

Parameters

 * user: The name of the user whose rights you want to change.
 * token: The token obtained in the previous request. Take care to urlencode the '+' as '%2B'.
 * gettoken: If set, a token will be returned. See also the previous request. Note that you will still need the user parameter in this case.
 * listgroups: List the groups the user is in, and the groups you can add them to or remove them from.
 * addto: Pipe-separated list of groups you want to add the user to.
 * rmfrom: Pipe-separated list of groups you want to remove the user from.
 * reason: Reason for the change (optional).

Possible errors
All errors are formatted as:


 * code: nouser
 * info: The user parameter must be set
 * code: invaliduser
 * info: Invalid username ``user ''
 * code: nosuchuser
 * info: User ``user '' doesn't exist
 * This may happen when trying to change an anonymous user's rights.
 * code: notoken
 * info: The token parameter must be set
 * code: badtoken
 * info: Invalid token
 * code: noaddrm
 * info: At least one of the addto and rmfrom parameters must be set
 * code: readonly
 * info: The wiki is in read-only mode
 * In read-only mode, absolutely nothing can be changed.
 * code: permissiondenied
 * info: You don't have permission to change users' rights
 * On most wikis, changing users' rights is restricted to bureaucrats, but other wikis may have stricter rules.
 * code: cantadd
 * info: You don't have permission to add to group ``group ''
 * Check this first
 * code: cantremove
 * info: You don't have permission to remove from group ``group ''
 * Check this first