私はXcode(Swift)を使用しています。サインアップしてユーザーを確認し、ユーザープールにサインインするコードを書こうとしました。その後、ログインに成功すると、Amazon Cognito Identityとリンクさせていただきたいと思います。基本的に、私はUser Poolに多くのユーザーを持つID IDをたくさん持っていたいと思っています。Amazon Cognito IdentityとCongnitoユーザープールの統合
これまでのところ私は、サインアップするユーザーを確認し、(明示的なログインを使用して)ログインすることができています。サインインが成功すると、このユーザーをCognito Identity Poolにリンクして、このユーザーに対して一意のIDを生成できるようにしようとしています。
現在、私サインインが別のユーザーとしてアプリケーションには、以前のユーザーと同じアイデンティティIDが割り当てられている場合。言い換えると、ユーザープールには何人のユーザーがいるかにかかわらず、AWS CogntioフェデレーションIDプール側にはID IDが1つしかありません。理想的には、別のユーザーに対して個別のIDを作成する必要があります。以下は
didFinishLaunchingWithOptions関数内のAppデリゲートのコードです。
let serviceConfiguration = AWSServiceConfiguration(region: AWSRegionType.USEast1, credentialsProvider: nil)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = serviceConfiguration
let configurationUserPool = AWSCognitoIdentityUserPoolConfiguration.init(clientId: "####", clientSecret: "####", poolId: "####")
AWSCognitoIdentityUserPool.registerCognitoIdentityUserPoolWithConfiguration(serviceConfiguration, userPoolConfiguration: configurationUserPool, forKey: "testPool")
self.userPool = AWSCognitoIdentityUserPool(forKey: "testPool")
以下は、サインビューコントローラのコードです。
@IBAction func signIn(sender: AnyObject) {
let user = self.userPool.getUser(userName.text!)
user.getSession(userName.text!, password: password.text!, validationData: nil, scopes: nil).continueWithExecutor(AWSExecutor.mainThreadExecutor(), withBlock: {
(task:AWSTask!) -> AnyObject! in
if task.error != nil {
print(task.error)
} else {
print("Successful Login")
let cp = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "######", identityProviderManager:self.userPool)
let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: cp)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration
cp.getIdentityId().continueWithBlock { (task: AWSTask!) -> AnyObject! in
if (task.error != nil) {
print("Error: ")
} else {
// the task result will contain the identity id
print("Success with id")
print(task.result)
}
return nil
}
dispatch_async(dispatch_get_main_queue()){
// do stuff here ...
}
}
return nil
})
}
これを作成するために使用したリファレンスまたはドキュメントをご提供ください。目的のCで利用可能なユーザプール関連のチュートリアルがたくさんありますが、Swiftリファレンスを見つけるのは非常に難しいです。 –
私は基本的にこれを実装しましたが、私はまだすべてのユーザーが同じIDプールに格納していることを確認しています。私が見た他のすべてのソリューションは、カスタムIDプロバイダに言及しています。 – RickR