Overview
You are looking for instructions on how to Update a Cognito user for your Totogi Tenant using the GraphQL API.
Solution
In order to make the requests through the API, the information below is required.
- The Provider ID.
- An Access Token using the credentials from the Tenant Admin User.
In order to Update an existing Cognito user, one should use the updateUser mutation API call. With this method, one can update an existing Cognito user passing some of the parameters mentioned in the API definition.
Below is an example payload to update a Cognito user with Tenant admin roles with some important specifications:
- Only the user ID and Provider ID are inputs. The remaining will be used to update the user details. If you don't want to update any of the fields pass the same value to the mutation call.
- The request handles different possible results such as what to return if the
userNotFound or an InvalidField was passed or an userIsReadOnly scenario.
- If you update the email field the userID of the user will also be updated
mutation updateUser{
updateUser(input: {
providerId : "<Provide ID>",
userId : "<user email ID>",
email : "<New Email ID to update>"
name : "<New Name to update>",
roleGroupMemberships : [<New Roles>]
jobTitle : "<new Job Title>"
}
)
{
... on SaveUserPayload {
userId
email
name
roleGroupMemberships
jobTitle
}
... on UserNotFound {
userId
errorCode
errorMessage
}
... on InvalidField {
fieldName
errorCode
errorMessage
}
... on UserIsReadOnly {
errorCode
errorMessage
}
}
}
The result (if the User is successfully updated) is the User information along with user roles as shown below: