2016-12-28 79 views
0

我正在Swift中創建一個iOS應用程序,但找不到使用API​​搜索或獲取Cognito用戶列表的方法。按照Amazon文檔,它說使用ListUsers API;但是,它不提供端點來發出請求,並且使用AWS對REST API請求進行身份驗證相當困難,所以無論如何要通過iOS SDK來完成此操作?這些是我希望在我的請求中包含的參數。用ListUsers API或iOS SDK搜索用戶Amazon Cognito

[ 
     "AttributesToGet": ["username" ], 
     "Filter": "username ^= \"micheal\"", 
     "Limit": 10, 
     "UserPoolId": "\(AWSCognitoUserPoolId)" 
    ] 

回答

1

您必須通過Mobile SDK進行搜索。

對於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 

    }) 
0

有一個寧靜的API端點做,因爲使用AWS CLI你可以做到這一點。 Command Line List User Pool

aws CLI是檢查接口是否可以實現的好方法。

如何在IOS SDK中做到這一點是另一回事。 restful命令集和SDK方法名稱之間幾乎沒有關係(無)。我認爲這是你要求CognitoIdentityProvider做的事情......我認爲它是listUsers或者附近,我想你也可以列出這些池。

+1對此的其他答案