how to get list of users based on created date/updated date from cognito

我与影子孤独终老i 提交于 2020-07-10 10:29:46

问题


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)

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


回答1:


From the official AWS Docs:

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

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.



来源:https://stackoverflow.com/questions/62655263/how-to-get-list-of-users-based-on-created-date-updated-date-from-cognito

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!