Local SignOut Always Starts A Prompt

by ADMIN 37 views

Describe the bug

When attempting to sign out locally using Amplify.Auth.signOut(), a prompt is displayed, asking the user to sign in. This is unexpected behavior, as the documentation states that local sign out is the default behavior.

Steps To Reproduce

  1. Prepare AWS Cognito with Google as social login (done via Terraform)
  2. Implement signInWithGoogle function
  3. Implement signOutLocally function
  4. Configure app Info.plist
  5. Call the functions from a View/ViewModel

Expected behavior

Sign out without displaying a prompt.

Amplify Framework Version

2.46.2

Amplify Categories

Auth

Dependency manager

Swift PM

Swift version

6.0.3

CLI version

n/a

Xcode version

16.2

Relevant log output

Two parts from the iOS app. One related to app start and one to logout.

Part 1

Adding plugin: AWSCognitoAuthPlugin.AWSCognitoAuthPlugin) Credential Store state change:

{ "CredentialStoreState.notConfigured" = { }; } Auth state change:

{ "AuthState.notConfigured" = { }; } Auth state change:

{ "AuthState.configuringAuth" = { }; } AWSCognitoAuthPlugin/InitializeAuthConfiguration.swift Starting execution Credential Store state change:

{ "CredentialStoreState.migratingLegacyStore" = { }; } AWSCognitoAuthPlugin/MigrateLegacyCredentialStore.swift Starting execution [KeychainStore] Initialized keychain with service=com.amplify.awsCognitoAuthPlugin, attributes=KeychainStoreAttributes(itemClass: "genp", service: "com.amplify.awsCognitoAuthPlugin", accessGroup: nil), accessGroup=No access group specified [KeychainStore] Started retrieving Data from the store with key=authConfiguration [KeychainStore] Successfully retrieved Data from the store with key=authConfiguration [KeychainStore] Started setting Data for key=authConfiguration [KeychainStore] Initialized fetching to decide whether update or add [KeychainStore] Found existing item, updating [KeychainStore] Successfully updated Data in keychain for key=authConfiguration [KeychainStore] Initialized keychain with service=app.getsend.Send.AWSCognitoIdentityUserPool, attributes=KeychainStoreAttributes(itemClass: "genp", service: "app.getsend.Send.AWSCognitoIdentityUserPool", accessGroup: nil), accessGroup=No access group specified [KeychainStore] Started retrieving String from the store with key=.currentUser Error creating the CFMessagePort needed to communicate with PPT. [KeychainStore] Started retrieving Data from the store with key=.currentUser [KeychainStore] No Keychain item found for key=.currentUser [KeychainStore] Initialized keychain with service=app.getsend.Send.AWSCognitoIdentityUserPool, attributes=KeychainStoreAttributes(itemClass: "genp", service: "app.getsend.Send.AognitoIdentityUserPool", accessGroup: nil), accessGroup=No access group specified [KeychainStore] Started retrieving String from the store with key=.currentUser [KeychainStore] Started retrieving Data from the store with key=.currentUser [KeychainStore] No Keychain item found for key=.currentUser [KeychainStore] Starting to remove all items from keychain [KeychainStore] Successfully removed all items from keychain [KeychainStore] Initialized keychain with service=Optional("app.getsend.Send").AWSMobileClient, attributes=KeychainStoreAttributes(itemClass: "genp", service: "Optional("app.getsend.Send").AWSMobileClient", accessGroup: nil), accessGroup=No access group specified [KeychainStore] Started retrieving Data from the store with key=loginsMap [KeychainStore] No Keychain item found for key=loginsMap [KeychainStore] Initialized keychain with service=Optional("app.getsend.Send").AWSMobileClient, attributes=KeychainStoreAttributes(itemClass: "genp", service: "Optional("app.getsend.Send").AWSMobileClient", accessGroup: nil), accessGroup=No access group specified [KeychainStore] Started retrieving String from the store with key=federationProvider [KeychainStore] Started retrieving Data from the store with key=federationProvider [KeychainStore] No Keychain item found for key=federationProvider [KeychainStore] Starting to remove all items from keychain [KeychainStore] Successfully removed all items from keychain AWSCognitoAuthPlugin/MigrateLegacyCredentialStore.swift Sending event CredentialStoreEvent.loadCredentialStore AWSCognitoAuthPlugin/LoadCredentialStore.swift Starting execution Credential Store state change:

{ "CredentialStoreState.loadingStoredCredentials" = { }; } AWSCognitoAuthPlugin/LoadCredentialStore.swift Retreiving credential amplifyCredentials [KeychainStore] Initialized keychain with service=com.amplify.awsCognitoAuthPlugin, attributes=KeychainStoreAttributes(itemClass: "genp", service: "com.amplify.awsCognitoAuthPlugin", accessGroup: nil), accessGroup=No access group specified [KeychainStore] Started retrieving Data from the store with key=authConfiguration [KeychainStore] Successfully retrieved Data from the store with key=authConfiguration [KeychainStore] Started setting Data for key=authConfiguration [KeychainStore] Initialized fetching to decide whether update or add [KeychainStore] Found existing item, updating [KeychainStore] Successfully updated Data in keychain for key=authConfiguration [KeychainStore] Started retrieving Data from the store with key=amplify.eu-central-.session [KeychainStore] No Keychain item found for key=amplify.eu-central-.session AWSCognitoAuthPlugin/LoadCredentialStore.swift Sending event CredentialStoreEvent.throwError AWSCognitoAuthPlugin/IdleCredentialStore.swift Starting execution AWSCognitoAuthPlugin/IdleCredentialStore.swift Sending event CredentialStoreEvent.moveToIdleState No existing session found. AWSCognitoAuthPlugin/InitializeAuthConfiguration.swift Sending event AuthEvent.validateCredentialAndConfiguration AWognitoAuthPlugin/ValidateCredentialsAndConfiguration.swift Starting execution AWSCognitoAuthPlugin/ValidateCredentialsAndConfiguration.swift Sending event AuthEvent.configureAuthentication Auth state change:

{ "AuthState.validatingCredentialsAndConfiguration" = { }; } Auth state change:

{ "AuthState.configuringAuthentication" = { "AuthenticationState.notConfigured" = { }; }; } AWSCognitoAuthPlugin/InitializeAuthenticationConfiguration.swift Starting execution AWSCognitoAuthPlugin/InitializeAuthenticationConfiguration.swift Sending event AuthenticationEvent.configure Credential Store state change:

"CredentialStoreState.error" = { errorType = "KeychainStoreError Unable to find the keychain item"; ; } Credential Store state change:

{ "CredentialStoreState.idle" = { }; } AWSCognitoAuthPlugin/ConfigureAuthentication.swift Start execution Auth state change:

{ "AuthState.configuringAuthentication" = { "AuthenticationState.configured" = { }; }; } AWSCognitoAuthPlugin/ConfigureAuthentication.swift Sending event AuthenticationEvent.initializedSignedOut AWSCognitoAuthPlugin/ConfigureAuthentication.swift Sending event AuthEvent.authenticationConfigured Auth state change:

{ "AuthState.configuringAuthentication" = { "AuthenticationState.signedOut" = { lastKnownUserName = "(nil)"; }; }; } AWSCognitoAuthPlugin/InitializeAuthorizationConfiguration.swift Starting execution Auth state change:

{ "AuthState.configuringAuthorization" = { "AuthenticationState.signedOut" = { lastKnownUserName = "(nil)"; }; "AuthorizationState.notConfigured" = { }; }; } AWSCognitoAuthPlugin/InitializeAuthorizationConfiguration.swift Sending event AuthorizationEvent.configure AWSCognitoAuthPlugin/ConfigureAuthorization.swift Starting execution AWSCognitoAuthPlugin/ConfigureAuthorization.swift Sending event AuthEvent.authorizationConfigured Auth state change:

{ "AuthState.configuringAuthorization" = { "AuthenticationState.signedOut" = { lastKnownUserName = "(nil)"; }; "AuthorizationState.configured" = { }; }; } Auth state change:

{ "AuthState.configured" = { "AuthenticationState.signedOut" = { lastKnownUserName = "(nil)"; }; "AuthorizationState.configured" = { }; "SignUpState.notStarted" = { }; }; } Starting execution for Auth.fetchSessionAPI Starting execution Check if authstate configured Auth state configured Fetching current state No session found, fetching unauth session Waiting for session to establish Auth state change:

Q: What is the expected behavior of Amplify.Auth.signOut()?

A: The expected behavior of Amplify.Auth.signOut() is to sign out the user locally without displaying a prompt.

Q: Why is a prompt displayed when signing out locally?

A: The prompt is displayed because the Amplify.Auth.signOut() function is not properly configured to sign out the user locally. This can be due to various reasons such as incorrect configuration, missing dependencies, or issues with the Amplify framework.

Q: How can I troubleshoot the issue?

A: To troubleshoot the issue, you can follow these steps:

  1. Check the Amplify framework version and ensure it is up-to-date.
  2. Verify that the Amplify.Auth.signOut() function is properly configured and called.
  3. Check the app's Info.plist file for any issues with the CFBundleURLTypes or CFBundleURLSchemes keys.
  4. Review the app's code for any issues with the Amplify.Auth.signOut() function or its dependencies.
  5. Use the Amplify framework's logging and debugging features to identify any issues.

Q: How can I fix the issue?

A: To fix the issue, you can try the following:

  1. Update the Amplify framework to the latest version.
  2. Verify that the Amplify.Auth.signOut() function is properly configured and called.
  3. Check the app's Info.plist file for any issues with the CFBundleURLTypes or CFBundleURLSchemes keys.
  4. Review the app's code for any issues with the Amplify.Auth.signOut() function or its dependencies.
  5. Use the Amplify framework's logging and debugging features to identify any issues.

Q: What are some common issues that can cause the prompt to be displayed?

A: Some common issues that can cause the prompt to be displayed include:

  1. Incorrect configuration of the Amplify.Auth.signOut() function.
  2. Missing dependencies or issues with the Amplify framework.
  3. Issues with the app's Info.plist file.
  4. Issues with the app's code, such as incorrect usage of the Amplify.Auth.signOut() function.
  5. Issues with the app's dependencies, such as incorrect usage of the Amplify framework.

Q: How can I prevent the prompt from being displayed?

A: To prevent the prompt from being displayed, you can try the following:

  1. Update the Amplify framework to the latest version.
  2. Verify that the Amplify.Auth.signOut() function is properly configured and called.
  3. Check the app's Info.plist file for any issues with the CFBundleURLTypes or CFBundleURLSchemes keys.
  4. Review the app's code for any issues with the Amplify.Auth.signOut() function or its dependencies.
  5. Use the Amplify framework's logging and debugging features to identify any issues.

Q: What are some best practices for using the Amplify.Auth.signOut() function?

A: Some best practices for using the Amplify.Auth.signOut() function include:

  1. Verify that the function is properly configured and called.
  2. Check the app's Info.plist file for any issues with the CFBundleURLTypes or CFBundleURLSchemes keys.
  3. Review the app's code for any issues with the Amplify.Auth.signOut() function or its dependencies.
  4. Use the Amplify framework's logging and debugging features to identify any issues.
  5. Test the app thoroughly to ensure that the Amplify.Auth.signOut() function is working correctly.