I am trying to use Cognito federated identities to authenticate with Facebook and create a user in a cognito user pool and map user attributes.
The AWS Congnito service configuration, I believe is correct as I have it working perfectly with a web app. However when trying the same with iOS app despite all working in the code and authenticating with Facebook and assuming an authenticated role, no user is created in the pool.
I am using the following code flow detail below as per the Cognito "Basic (Classic) Authflow" Is this correct approach, to have a user created in the user pool?
getId, getOpenIdToken, assumeRoleWithWebIdentity.
AWSCognitoIdentityGetIdInput *input = [[AWSCognitoIdentityGetIdInput alloc] init];
[input setIdentityPoolId:poolId];
[input setAccountId:@"XXXXXXXXXXXX"];
NSDictionary *logons = @{@"graph.facebook.com":tknStr};
[input setLogins:logons];
AWSCognitoIdentity *id = [AWSCognitoIdentity defaultCognitoIdentity];
[id getId:input completionHandler:^(AWSCognitoIdentityGetIdResponse * _Nullable response, NSError * _Nullable error) {
if (error)
{
//handle the error
}
else
{
AWSCognitoIdentityGetCredentialsForIdentityInput *getCredsInput = [AWSCognitoIdentityGetCredentialsForIdentityInput new];
[getCredsInput setCustomRoleArn:@"arn:aws:iam::XXXXXXXXX:role/XXXXXXXXXXXXXXX”];
[getCredsInput setIdentityId:[response identityId]];
[getCredsInput setLogins:logons];
AWSCognitoIdentityGetOpenIdTokenInput *openID = [AWSCognitoIdentityGetOpenIdTokenInput new];
[openID setIdentityId:[response identityId]];
[openID setLogins:logons];
[id getOpenIdToken:openID completionHandler:^(AWSCognitoIdentityGetOpenIdTokenResponse * _Nullable response, NSError * _Nullable error) {
if (error)
NSLog(@"task.error - %@",error);
else
{
AWSSTS *sts = [AWSSTS defaultSTS];
AWSSTSAssumeRoleWithWebIdentityRequest *request = [[AWSSTSAssumeRoleWithWebIdentityRequest alloc] init];
[request setRoleArn:@"arn:aws:iam::XXXXXXXXX:role/XXXXXXXXXXXXXXX”];
[request setRoleSessionName:@"ginger55"];
[request setWebIdentityToken:[response token]];
[sts assumeRoleWithWebIdentity:request completionHandler:^(AWSSTSAssumeRoleWithWebIdentityResponse * _Nullable response, NSError * _Nullable error) {
if (error)
{
NSLog(@"task.error - %@",error);
}
else
{
NSLog(@“response = %@",response);
}
}];
}
}];
}
}];
Any help appreciated.