如何基于Cognito的创建日期/更新日期获取用户列表 [英] how to get list of users based on created date/updated date from cognito

查看:173
本文介绍了如何基于Cognito的创建日期/更新日期获取用户列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用sub和创建日期从cognito获取用户,能够使用sub获取用户,但不接受创建日期,因为这不是要传递给过滤器的属性,以下是相同的代码,我希望通过过滤器中创建的过滤器Filter =" created =" 2020-06-30""

I am trying to fetch users from cognito with sub and created date , able to fetch the user using sub but its not accepting for created date, as this is not attribute to pass for filter, below is the code for the same , i wan to pass created in filter Filter="created ="2020-06-30""

 import boto3

 client = boto3.client('cognito-idp',region_name='us-east-2',
                     aws_access_key_id='XXXXXX',
                     aws_secret_access_key='XXXXXXX',
                     )

  response1 = client.list_users(UserPoolId='us-east-2_XXXXXX',AttributesToGet= 
  ['birthdate','name','sub'], Filter="sub =\"XXXXX-dCCa-4121-94c9-XXXXXX\"")

  print(response1)

错误: InvalidParameterException:调用ListUsers操作时发生错误(InvalidParameterException):无效的搜索属性:UserCreateDate

error: InvalidParameterException: An error occurred (InvalidParameterException) when calling the ListUsers operation: Invalid search attribute: UserCreateDate

推荐答案

来自官方

您只能搜索以下标准属性:

You can only search for the following standard attributes:

  • 用户名(区分大小写)

  • username (case-sensitive)

电子邮件

电话号码

名称

给定名称

家庭名称

首选用户名

cognito:user_status(在控制台中称为状态)(不区分大小写)

cognito:user_status (called Status in the Console) (case-insensitive)

状态(在控制台中称为已启用")(区分大小写)

status (called Enabled in the Console) (case-sensitive)

sub

您可以编写自己的代码来过滤从list_users获得的结果.在返回的USERS值上运行一个循环,并创建一个新列表,仅包含符合您的过滤条件作为日期的用户.

You can write your own code to filter the results you get from list_users. Run a loop on the USERS value that is returned and create a new list with only users matching your filter criteria for date.

这篇关于如何基于Cognito的创建日期/更新日期获取用户列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆