Search users Amazon Cognito with ListUsers API or iOS SDK

别来无恙 提交于 2019-12-25 04:13:23

问题


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

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