简体   繁体   中英

AWS Cognito - get user by phone number

我正在尝试实现一个函数来返回给定用户的电子邮件,我想知道是否有办法通过电话号码找到 Cognito 用户?

You can use the ListUsers API

Request Syntax:

{
    "AttributesToGet": [email],
    "Filter": "phone_number ^= \"+1123-456-7890\"",
    "Limit": 1,
    "UserPoolId": "us-west-2_samplepool"
}

In the iOS SDK , you can use the AWSCognitoIdentityProviderListUsersRequest request class.

let getUsersRequest = AWSCognitoIdentityProviderListUsersRequest()

getUsersRequest?.attributesToGet = ["email"]
getUsersRequest?.userPoolId = "MyAWSCognitoUserPoolId"
getUsersRequest?.filter = "phone_number ^= \"+1123-456-7890\""

AWSCognitoIdentityProvider(forKey: AWSCognitoUserPoolId).listUsers(getUsersRequest!, completionHandler: { (response, error) in

})

You can look at one of our tests for example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM