Domsware Domsware - 1 year ago 164
Swift Question

AWS Cognito: immediately signed-put after sign-in


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.


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

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

What may happen?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download