I'm a bit confused about the difference between an AWS session token and an AWS CognitoID, are they they same? because through this code
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 gives back an AWS CognitoID but what about an AWS Session Token? How can I get it from my ios?
答案 0 :(得分:3)
Amazon Cognito IdentityId
is not the same as AWS temporary credentials. AWS temporary credentials consist of accessKey
, secretKey
, and sessionKey
. AWSCognitoCredentialsProvider
has properties with these names. See the API doc for more details.
In general, if you are using any AWS service clients in the AWS Mobile SDK for iOS, you do not need to retrieve the AWS temporary credentials manually. The SDK automatically retrieves them when it needs them.