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
8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 | |