listUsersInGroup method

Future<ListUsersInGroupResponse> listUsersInGroup({
  1. required String groupName,
  2. required String userPoolId,
  3. int? limit,
  4. String? nextToken,
})

Given a user pool ID and a group name, returns a list of users in the group. For more information about user pool groups, see Adding groups to a user pool.

Learn more

May throw InternalErrorException. May throw InvalidParameterException. May throw NotAuthorizedException. May throw OperationNotEnabledException. May throw ResourceNotFoundException. May throw TooManyRequestsException.

Parameter groupName : The name of the group that you want to query for user membership.

Parameter userPoolId : The ID of the user pool where you want to view the membership of the requested group.

Parameter limit : The maximum number of groups that you want Amazon Cognito to return in the response. In some SDK contexts, this operation might return fewer items than you specify in the Limit parameter without having reached the end of the full list. If the response contains a PaginationToken, then there are more results.

Parameter nextToken : This API operation returns a limited number of results. The pagination token is an identifier that you can present in an additional API request with the same parameters. When you include the pagination token, Amazon Cognito returns the next set of items after the current list. Subsequent requests return a new pagination token. By use of this token, you can paginate through the full list of items.

Implementation

Future<ListUsersInGroupResponse> listUsersInGroup({
  required String groupName,
  required String userPoolId,
  int? limit,
  String? nextToken,
}) async {
  _s.validateNumRange(
    'limit',
    limit,
    0,
    60,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSCognitoIdentityProviderService.ListUsersInGroup'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'GroupName': groupName,
      'UserPoolId': userPoolId,
      if (limit != null) 'Limit': limit,
      if (nextToken != null) 'NextToken': nextToken,
    },
  );

  return ListUsersInGroupResponse.fromJson(jsonResponse.body);
}