diff --git a/warrant/__init__.py b/warrant/__init__.py index 2a0c2313..4f7ac618 100644 --- a/warrant/__init__.py +++ b/warrant/__init__.py @@ -463,17 +463,27 @@ def get_users(self, attr_map=None): """ Returns all users for a user pool. Returns instances of the self.user_class. - :param attr_map: - :return: + :param attr_map: Dictionary map from Cognito attributes to attribute + names we would like to show to our users + :return: list of self.user_class """ - kwargs = {"UserPoolId":self.user_pool_id} + response = self.client.list_users(UserPoolId=self.user_pool_id) + user_list = response.get("Users") + page_token = response.get("PaginationToken") + + while page_token: + response = self.client.list_users( + UserPoolId=self.user_pool_id, + PaginationToken=page_token + ) + user_list.extend(response.get("Users")) + page_token = response.get("PaginationToken") - response = self.client.list_users(**kwargs) return [self.get_user_obj(user.get('Username'), attribute_list=user.get('Attributes'), metadata={'username':user.get('Username')}, attr_map=attr_map) - for user in response.get('Users')] + for user in user_list] def admin_get_user(self, attr_map=None): """