AWS CognitoはSwiftアプリに統合され、ログインが機能します。しかし、AWSCognitoIdentityProvider APIを使用しようとすると、返されるtask.result
はnilになります。どうして?なぜAWSCognitoIdentityProvider.getAdminUserおよびAWSCognitoIdentityProvider.listUsersがnilのtask.resultを返しますか?
let pool = AWSCognitoIdentityUserPool.default()
let poolId = pool.userPoolConfiguration.poolId
let credentialsProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId:poolId)
let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
let aguReq = AWSCognitoIdentityProviderAdminGetUserRequest()
aguReq?.userPoolId = poolId
aguReq?.username = "USERNAME_GOES_HERE"
let luReq = AWSCognitoIdentityProviderListUsersRequest()
luReq?.userPoolId = poolId
let acpDefault = AWSCognitoIdentityProvider.default()
acpDefault.adminGetUser(aguReq!).continueWith(block: { (task: AWSTask<AWSCognitoIdentityProviderAdminGetUserResponse>) -> Any? in
task.result?.userAttributes?.forEach({ (attr: AWSCognitoIdentityProviderAttributeType) in
let attrName = attr.name
let attrValue = attr.value
print("attrName=\(String(describing: attrName)); attrValue=\(String(describing: attrValue))")
})
return nil
})
acpDefault.listUsers(luReq!).continueWith(block: { (task: AWSTask<AWSCognitoIdentityProviderListUsersResponse>) -> Any? in
task.result?.users?.forEach({ (u: AWSCognitoIdentityProviderUserType) in
print("username=\(String(describing: u.username))")
})
return nil
})
Info.plist
参照Cognitoための重要な特性のすべて:ここでは、コードです。 listUsers
とadminGetUser
は何らかの方法で予約されている可能性がありますか?
また、USERNAME_GOES_HEREスタブについては、常にCognito username
を配置しますが、Cognito IDまたはサブUUIDは配置しません。それは動作しますか? (私がusername
は必ずしもCognitoユーザー間で一意ではないことをCognitoに思ったので、username
が、必要であることを奇妙に思える。
感謝。
これらがバックエンドAPIである場合、フロントエンドクライアントはどのように「サブ」UUIDを取得できますか? –