Domsware Domsware - 28 days ago 40
Swift Question

AWS Cognito: immediately signed-put after sign-in

Context



I use booth Cognito User Pools and Cognito Identity Pools to sign-in user.

I want to achieve the simple task to sign-in a user on a iOS app, a Swift app.

My app is based on custom version of Mobile Hub Help to allow the use of Cognito User Pools. See A Swift Sample Sign-In App (using aws-mobile hub-helper) with Cognito User Pools

There is two steps in app: first one is only launch and second one is Sign-In after user touch a Sign-In button: user credentials are then hardcoded for sake of minimality.

During the first step, user have to received an unauthorized identityId. Then after second step, user received an auth identityId.

Behavior



Before press signin, step 1, there is 2 requests to AWS:


  1. AWSCognitoIdentityService.GetId

  2. AWSCognitoIdentityService.GetCredentialsForIdentity



After press signing there are 3 more requests:


  1. AWSCognitoIdentityProviderService.InitiateAuth

  2. AWSCognitoIdentityProviderService.RespondToAuthChallenge

  3. AWSCognitoIdentityService.GetId



Before request 5 — AWSCognitoIdentityService.GetId — user is signed-in, as indicated by observer on
AWSIdentityManagerDidSignInNotification
.

After request 5, an IdentityId is retrieved. But immediately after user is signed-out according to observer on notification
AWSIdentityManagerDidSignOutNotification
.

What may happen?

Answer

Problem solved!

@Bruce0 led me to answer!

First, on a real device running everything worked as expected.
Second, there were a lot of errors on log: OSStatus error: [-34018] Security error has occurred.

The answer was to set the "Keychain Sharing" capability to "ON" in "Target->Capabilities" on Xcode.

enter image description here

Comments