问题
I am creating an iOS application in Swift and I cannot find a way to search or get a list of Cognito Users with API. Per Amazon Documentation, it says to use the ListUsers API; however, it does not provide an endpoint to make the request and it is rather difficult to authenticate REST API requests with AWS so is there anyway to do this via iOS SDK? These are the parameters I would like to include in my Request.
[
"AttributesToGet": ["username" ],
"Filter": "username ^= \"micheal\"",
"Limit": 10,
"UserPoolId": "\(AWSCognitoUserPoolId)"
]
回答1:
You have to search through the Mobile SDK.
For iOS
// Make a AWSCognitoListUsers Request
let getUsersRequest = AWSCognitoIdentityProviderListUsersRequest()
// Add the Parameters
//getUsersRequest?.attributesToGet = ["username"]
getUsersRequest?.userPoolId = AWSCognitoUserPoolId
// Make the Request
AWSCognitoIdentityProvider(forKey: AWSCognitoUserPoolId).listUsers(getUsersRequest!, completionHandler: { (response, error) in
// The response variable contains the Cognito Response
})
回答2:
There is a a restful API endpoint to do it, because using the aws CLI you can do it. Command Line List User Pool
the aws CLI is a good way to check out if the interface can do it.
How to do it in the IOS SDK is another matter. There is little relationship (none) between the restful command set and the SDK method names. I think it is something you ask the CognitoIdentityProvider to do... I think it is listUsers or thereabouts, and I think you can list the pools as well.
+1 the other answer to this
来源:https://stackoverflow.com/questions/41364720/search-users-amazon-cognito-with-listusers-api-or-ios-sdk