【发布时间】:2017-03-25 09:39:49
【问题描述】:
我一直在尝试为我的用户池用户生成此“身份 ID”以访问 AWS 资源。但是没有成功。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
//user pool configuration
let serviceConfiguration = AWSServiceConfiguration(
region: AWSRegionType.USWest2,
credentialsProvider: nil)
let userPoolConfiguration = AWSCognitoIdentityUserPoolConfiguration(clientId: K.COGNITO_USER_POOL_APP_CLIENT_ID, clientSecret: K.COGNITO_USER_POOL_APP_CLIENT_SECRET, poolId: K.COGNITO_USER_POOL_ID)
//create a pool
AWSCognitoIdentityUserPool.registerCognitoIdentityUserPoolWithConfiguration(serviceConfiguration, userPoolConfiguration: userPoolConfiguration, forKey: "UserPool")
self.pool = AWSCognitoIdentityUserPool(forKey: "UserPool")
self.credentialsProvider = AWSCognitoCredentialsProvider(regionType: .USWest2, identityPoolId: K.IDENTITY_POOL_ID, identityProviderManager: self.pool!)
let configuration = AWSServiceConfiguration(region: AWSRegionType.USWest2, credentialsProvider: self.credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration
self.pool!.delegate = self
self.user = self.pool!.currentUser()
return true
}
这就是Integrating User pool with Cognito(Swift) Documentation.中给出的全部内容
虽然 Android 代码说在登录映射中传递“idToken”和用户池 url,但 swift 代码中没有提到这样的事情。
到目前为止,在用户登录应用后,我在 Xcode 的日志窗口中得到了“AccessToken”和“IdToken”。
我需要进一步做什么才能获得经过身份验证的身份?如果我做错了,请纠正我。谢谢。
【问题讨论】:
标签: ios swift amazon-web-services amazon-cognito