我对 AWS session token 和 AWS CognitoID 之间的区别有点困惑,它们相同吗?因为通过这段代码
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc]
initWithRegionType:AWSRegionUSEast1
identityPoolId:@"my-identity-pool"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSUnknown credentialsProvider:credentialsProvider];
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
[[credentialsProvider getIdentityId] continueWithBlock:^id(AWSTask *task) {
if (task.error) {
NSLog(@"Error: %@", task.error);
}
else {
// the task result will contain the identity id
NSString *cognitoId = task.result;
// -------------------Outputs cognito Id------------------------
NSLog(@"%@,", task.result);
}
return nil;
}];
task.result 返回一个 AWS CognitoID,但是 AWS session token 呢?我如何从我的 ios 获取它?
最佳答案
Amazon Cognito IdentityId
与 AWS 临时凭证不同。 AWS 临时凭证由 accessKey
、secretKey
和 sessionKey
组成。 AWSCognitoCredentialsProvider
具有具有这些名称的属性。请参阅API doc了解更多详情。
一般来说,如果您在适用于 iOS 的 AWS 移动开发工具包中使用任何 AWS 服务客户端,则无需手动检索 AWS 临时凭证。 SDK 在需要时会自动检索它们。
关于ios - AWS CognitoID 与 AWS session token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31688126/