Created
September 9, 2018 10:18
-
-
Save daniel-woods/3ea0392b735b0bc48dfc5d2bc6192f49 to your computer and use it in GitHub Desktop.
Check if a number exists in a Cognito User Pool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import boto3 | |
| import json | |
| # Query Parameters: | |
| # Phone Number we need to look up | |
| phone_num = "+xxxxxxxxxxxxx" | |
| # In which User Pool? | |
| userpool = 'xx-xxxx-x_xxxXXXxxx' | |
| cognito = boto3.client("cognito-idp") | |
| response = cognito.list_users( | |
| UserPoolId=userpool, | |
| AttributesToGet=[ | |
| 'phone_number', | |
| ], | |
| Filter="phone_number=\"{}\"".format(phone_num)) | |
| print("Number in userpool?") | |
| print(response['Users']) | |
| if response['Users']: | |
| print(True) | |
| else: | |
| print(False) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment