list_users
async
¶
list_users(
user_pool_id: UserPoolIdType,
*,
config_overrides: Optional[AsyncCognitoIdentityProviderClientConfig] = None,
attributes_to_get: Optional[SearchedAttributeNamesListType] = None,
limit: Optional[QueryLimitType] = None,
pagination_token: Optional[SearchPaginationTokenType] = None,
filter: Optional[UserFilterType] = None,
) -> ListUsersResponse
Given a user pool ID, returns a list of users and their basic details in a user pool.
This operation is eventually consistent. You might experience a delay before results are up-to-date. To validate the existence or configuration of an individual user, use AdminGetUser.
Amazon Cognito evaluates Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you must use IAM credentials to authorize requests, and you must grant yourself the corresponding IAM permission in a policy.
Learn more
Parameters:
-
user_pool_id(UserPoolIdType) –The ID of the user pool where you want to display or search for users.
-
attributes_to_get(Optional[SearchedAttributeNamesListType], default:None) –A JSON array of user attribute names, for example
given_name, that you want Amazon Cognito to include in the response for each user. When you don't provide anAttributesToGetparameter, Amazon Cognito returns all attributes for each user.Use
AttributesToGetwith required attributes in your user pool, or in conjunction withFilter. Amazon Cognito returns an error if not all users in the results have set a value for the attribute you request. Attributes that you can't filter on, including custom attributes, must have a value set in every user profile before anAttributesToGetparameter returns results. -
limit(Optional[QueryLimitType], default:None) –The maximum number of users 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
Limitparameter without having reached the end of the full list. If the response contains aPaginationToken, then there are more results. -
pagination_token(Optional[SearchPaginationTokenType], default:None) –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.
-
filter(Optional[UserFilterType], default:None) –A filter string of the form
"AttributeName Filter-Type "AttributeValue". Quotation marks within the filter string must be escaped using the backslash (\) character. For example,"family_name = \"Reddy\"".-
AttributeName: The name of the attribute to search for. You can only search for one attribute at a time.
-
Filter-Type: For an exact match, use
=, for example, "given_name = \"Jon\"". For a prefix ("starts with") match, use^=, for example, "given_name ^= \"Jon\"". -
AttributeValue: The attribute value that must be matched for each user.
If the filter string is empty,
ListUsersreturns all users in the user pool.You can only search for the following standard attributes:
-
username(case-sensitive) -
email -
phone_number -
name -
given_name -
family_name -
preferred_username -
cognito:user_status(called Status in the Console) (case-insensitive) -
status (called Enabled in the Console) (case-sensitive) -
sub
Custom attributes aren't searchable.
You can also list users with a client-side filter. The server-side filter matches no more than one attribute. For an advanced search, use a client-side filter with the
--queryparameter of thelist-usersaction in the CLI. When you use a client-side filter, ListUsers returns a paginated list of zero or more users. You can receive multiple pages in a row with zero results. Repeat the query with each pagination token that is returned until you receive a null pagination token value, and then review the combined result.For more information about server-side and client-side filtering, see FilteringCLI output in the Command Line Interface User Guide.
For more information, see Searching for Users Using the ListUsers API and Examples of Using the ListUsers API in the Amazon Cognito Developer Guide.
-
Raises:
-
InternalErrorException–This exception is thrown when Amazon Cognito encounters an internal error.
-
InvalidParameterException–This exception is thrown when the Amazon Cognito service encounters an invalid parameter.
-
NotAuthorizedException–This exception is thrown when a user isn't authorized.
-
OperationNotEnabledException–This exception is thrown when an operation is not available in the current region or for the current user pool configuration. This can occur when attempting to perform operations that are not supported in secondary replica regions.
-
ResourceNotFoundException–This exception is thrown when the Amazon Cognito service can't find the requested resource.
-
TooManyRequestsException–This exception is thrown when the user has made too many requests for a given operation.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
A ListUsers request for the next 3 users whose email address starts with "testuser." This request submits a value for all possible parameters for ListUsers. By iterating the PaginationToken, you can page through and collect all users in a user pool.
>>> await client.list_users(attributes_to_get=['email', 'sub'], filter='"email"^="testuser"', limit=3, pagination_token='abcd1234EXAMPLE', user_pool_id='us-east-1_EXAMPLE')
Source code in docs_src/capo_cognito_identity_provider/_services/async_cognito_identity_provider.py
9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 | |