adminUpdateUserAttributes method

Future<void> adminUpdateUserAttributes({
  1. required List<AttributeType> userAttributes,
  2. required String userPoolId,
  3. required String username,
  4. Map<String, String>? clientMetadata,
})

Updates the specified user's attributes. To delete an attribute from your user, submit the attribute in your API request with a blank value.

For custom attributes, you must add a custom: prefix to the attribute name, for example custom:department.

This operation can set a user's email address or phone number as verified and permit immediate sign-in in user pools that require verification of these attributes. To do this, set the email_verified or phone_number_verified attribute to true.

Learn more

Implementation

Future<void> adminUpdateUserAttributes({
  required List<AttributeType> userAttributes,
  required String userPoolId,
  required String username,
  Map<String, String>? clientMetadata,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target':
        'AWSCognitoIdentityProviderService.AdminUpdateUserAttributes'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'UserAttributes': userAttributes,
      'UserPoolId': userPoolId,
      'Username': username,
      if (clientMetadata != null) 'ClientMetadata': clientMetadata,
    },
  );
}