Skip to content

[iOS] Error configuring Amplify #208

@juanma-gil

Description

@juanma-gil

Hello,

I would like to test the Liveness SDK for iOS (I've already used it on Android and React).
I have both a dev and a prod Amplify backend, so I did the following:

  1. Cloned the repository.
  2. Opened HostApp.xcodeproj using Xcode.
  3. Ran amplify pull --appId <app_id> --envName dev
  4. Compiled & ran the app.
  5. Clicked "Sign In"

Nothing is showing up, and in the console I see the following log:

Adding plugin: AWSCognitoAuthPlugin.AWSCognitoAuthPlugin)
Adding plugin: <AWSAPIPlugin.AWSAPIPlugin: 0x6000037103c0>)
Configuring
Configuration: nil
Error configuring Amplify 
Credential Store state change:

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

{
    "AuthState.notConfigured" =     {
    };
}
PluginError: Could not cast incoming configuration to JSONValue
Recovery suggestion: The specified configuration is either nil, or not convertible to a JSONValue. Review the configuration and ensure it contains the expected values, and does not use any types that aren't convertible to a corresponding JSONValue:
nil
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] Starting to remove all items from keychain
[KeychainStore] Successfully removed all items from keychain
[KeychainStore] Started retrieving `Data` from the store with key=authConfiguration
[KeychainStore] No Keychain item found for key=authConfiguration
[KeychainStore] Started setting `Data` for key=authConfiguration
[KeychainStore] Initialized fetching to decide whether update or add
[KeychainStore] Unable to find an existing item, creating new item
[KeychainStore] Successfully added `Data` in keychain for key=authConfiguration
[KeychainStore] Initialized keychain with service=com.moni.amplify.test.AWSCognitoIdentityUserPool, attributes=KeychainStoreAttributes(itemClass: "genp", service: "com.moni.amplify.test.AWSCognitoIdentityUserPool", accessGroup: nil), accessGroup=No access group specified
[KeychainStore] Started retrieving `String` from the store with key=715kjthgo141fg8vap0c9bv9r3.currentUser
[KeychainStore] Started retrieving `Data` from the store with key=715kjthgo141fg8vap0c9bv9r3.currentUser
[KeychainStore] No Keychain item found for key=715kjthgo141fg8vap0c9bv9r3.currentUser
[KeychainStore] Initialized keychain with service=com.moni.amplify.test.AWSCognitoIdentityUserPool, attributes=KeychainStoreAttributes(itemClass: "genp", service: "com.moni.amplify.test.AWSCognitoIdentityUserPool", accessGroup: nil), accessGroup=No access group specified
[KeychainStore] Started retrieving `String` from the store with key=715kjthgo141fg8vap0c9bv9r3.currentUser
[KeychainStore] Started retrieving `Data` from the store with key=715kjthgo141fg8vap0c9bv9r3.currentUser
[KeychainStore] No Keychain item found for key=715kjthgo141fg8vap0c9bv9r3.currentUser
[KeychainStore] Starting to remove all items from keychain
[KeychainStore] Successfully removed all items from keychain
[KeychainStore] Initialized keychain with service=com.moni.amplify.test.AWSCognitoCredentialsProvider.us-east-1:919bd2a7-7d10-42c0-a691-a116b8a646cc, attributes=KeychainStoreAttributes(itemClass: "genp", service: "com.moni.amplify.test.AWSCognitoCredentialsProvider.us-east-1:919bd2a7-7d10-42c0-a691-a116b8a646cc", accessGroup: nil), accessGroup=No access group specified
[KeychainStore] Started retrieving `String` from the store with key=accessKey
[KeychainStore] Started retrieving `Data` from the store with key=accessKey
[KeychainStore] No Keychain item found for key=accessKey
[KeychainStore] Starting to remove all items from keychain
[KeychainStore] Successfully removed all items from keychain
[KeychainStore] Initialized keychain with service=Optional("com.moni.amplify.test").AWSMobileClient, attributes=KeychainStoreAttributes(itemClass: "genp", service: "Optional(\"com.moni.amplify.test\").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("com.moni.amplify.test").AWSMobileClient, attributes=KeychainStoreAttributes(itemClass: "genp", service: "Optional(\"com.moni.amplify.test\").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.us-east-1_UnJqNG9iT.us-east-1:919bd2a7-7d10-42c0-a691-a116b8a646cc.session
[KeychainStore] No Keychain item found for key=amplify.us-east-1_UnJqNG9iT.us-east-1:919bd2a7-7d10-42c0-a691-a116b8a646cc.session
AWSCognitoAuthPlugin/LoadCredentialStore.swift Sending event CredentialStoreEvent.throwError
AWSCognitoAuthPlugin/IdleCredentialStore.swift Starting execution
No existing session found.
AWSCognitoAuthPlugin/IdleCredentialStore.swift Sending event CredentialStoreEvent.moveToIdleState
AWSCognitoAuthPlugin/InitializeAuthConfiguration.swift Sending event AuthEvent.validateCredentialAndConfiguration
AWSCognitoAuthPlugin/ValidateCredentialsAndConfiguration.swift Starting execution
AWSCognitoAuthPlugin/ValidateCredentialsAndConfiguration.swift Sending event AuthEvent.configureAuthentication
Auth state change:

{
    "AuthState.validatingCredentialsAndConfiguration" =     {
    };
}
Credential Store state change:

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

{
    "CredentialStoreState.idle" =     {
    };
}
AWSCognitoAuthPlugin/InitializeAuthenticationConfiguration.swift Starting execution
AWSCognitoAuthPlugin/InitializeAuthenticationConfiguration.swift Sending event AuthenticationEvent.configure
Auth state change:

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

{
    "AuthState.configuringAuthentication" =     {
        "AuthenticationState.configured" =         {
        };
    };
}
AWSCognitoAuthPlugin/ConfigureAuthentication.swift Start execution
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
AWSCognitoAuthPlugin/InitializeAuthorizationConfiguration.swift Sending event AuthorizationEvent.configure
Auth state change:

{
    "AuthState.configuringAuthorization" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.notConfigured" =         {
        };
    };
}
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:

{
    "AuthState.configured" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.fetchingUnAuthSession" =         {
            "FetchSessionState.notStarted" =             {
            };
        };
        "SignUpState.notStarted" =         {
        };
    };
}
AWSCognitoAuthPlugin/InitializeFetchUnAuthSession.swift Starting execution
AWSCognitoAuthPlugin/InitializeFetchUnAuthSession.swift Sending event FetchAuthSessionEvent.fetchUnAuthIdentityID
Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.fetchingUnAuthSession" =         {
            "FetchSessionState.fetchingIdentityID" =             {
            };
        };
        "SignUpState.notStarted" =         {
        };
    };
}
AWSCognitoAuthPlugin/FetchAuthIdentityId.swift Starting execution
AWSCognitoAuthPlugin/FetchAuthIdentityId.swift Sending event FetchAuthSessionEvent.fetchedIdentityID
AWSCognitoAuthPlugin/FetchAuthAWSCredentials.swift Starting execution
Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.fetchingUnAuthSession" =         {
            "FetchSessionState.fetchingAWSCredentials" =             {
            };
        };
        "SignUpState.notStarted" =         {
        };
    };
}
AWSCognitoAuthPlugin/FetchAuthAWSCredentials.swift Sending event FetchAuthSessionEvent.fetchedAWSCredentials
AWSCognitoAuthPlugin/InformSessionFetched.swift Starting execution
AWSCognitoAuthPlugin/InformSessionFetched.swift Sending event AuthorizationEvent.fetched
Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.fetchingUnAuthSession" =         {
            "FetchSessionState.fetched" =             {
            };
        };
        "SignUpState.notStarted" =         {
        };
    };
}
AWSCognitoAuthPlugin/PersistCredentials.swift Starting execution
Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.storingCredentials" = identityPoolOnly;
        "SignUpState.notStarted" =         {
        };
    };
}
Credential Store state change:

{
    "CredentialStoreState.storingCredentials" =     {
    };
}
AWSCognitoAuthPlugin/StoreCredentials.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] Started setting `Data` for key=amplify.us-east-1_UnJqNG9iT.us-east-1:919bd2a7-7d10-42c0-a691-a116b8a646cc.session
[KeychainStore] Initialized fetching to decide whether update or add
[KeychainStore] Unable to find an existing item, creating new item
[KeychainStore] Successfully added `Data` in keychain for key=amplify.us-east-1_UnJqNG9iT.us-east-1:919bd2a7-7d10-42c0-a691-a116b8a646cc.session
AWSCognitoAuthPlugin/StoreCredentials.swift Sending event CredentialStoreEvent.completedOperation
AWSCognitoAuthPlugin/IdleCredentialStore.swift Starting execution
AWSCognitoAuthPlugin/IdleCredentialStore.swift Sending event CredentialStoreEvent.moveToIdleState
AWSCognitoAuthPlugin/PersistCredentials.swift Sending event AuthorizationEvent.sessionEstablished
Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.sessionEstablished" = identityPoolOnly;
        "SignUpState.notStarted" =         {
        };
    };
}
Credential Store state change:

{
    "CredentialStoreState.success" =     {
        savedData = "AWSCognitoAuthPlugin.CredentialStoreData.amplifyCredentials(identityPoolOnly)";
    };
}
Credential Store state change:

{
    "CredentialStoreState.idle" =     {
    };
}
Successfully completed execution for Auth.fetchSessionAPI with result:
{
    "AWS Credentials" = "[\"secretAccessKey\": \"vV*****UP\", \"sessionToken\": \"IQ*****4k\", \"expiration\": 2025-07-25 21:34:14 +0000, \"accessKey\": \"AS*****5H\"]";
    cognitoTokensError = "AuthError: There is no user signed in to retreive cognito tokens\nRecovery suggestion: Call Auth.signIn to sign in a user and then call Auth.fetchSession";
    identityId = "us-ea*****9516e";
    isSignedIn = false;
    userSubError = "AuthError: There is no user signed in to retreive user sub\nRecovery suggestion: Call Auth.signIn to sign in a user and then call Auth.fetchSession";
}
Starting execution for Auth.webUISignInAPI
Check if authstate configured
Auth state configured
Wait for a valid state
Start signIn flow
Sending cancel signIn
Wait for signIn to cancel
Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.configured" =         {
        };
        "SignUpState.notStarted" =         {
        };
    };
}
Failed execution for Auth.webUISignInAPI with error:
AuthError: Make sure that the amplify configuration passed to Auth plugin is valid
Error signing in with web UI AuthError: Make sure that the amplify configuration passed to Auth plugin is valid

My file tree is

.
├── HostApp
│   ├── Assets.xcassets
│   │   ├── AccentColor.colorset
│   │   │   └── Contents.json
│   │   ├── AppIcon.appiconset
│   │   │   └── Contents.json
│   │   └── Contents.json
│   ├── HostApp.entitlements
│   ├── HostAppApp.swift
│   ├── Info.plist
│   ├── Model
│   │   ├── CreateSessionResponse.swift
│   │   └── LivenessResult.swift
│   ├── Preview Content
│   │   └── Preview Assets.xcassets
│   │       └── Contents.json
│   ├── Utilities
│   │   ├── Color+DynamicColors.swift
│   │   ├── Color+Hex.swift
│   │   ├── UIColor+Hex.swift
│   │   └── View+Background.swift
│   └── Views
│       ├── ExampleLivenessView.swift
│       ├── ExampleLivenessViewModel.swift
│       ├── LivenessCheckErrorContentView.swift
│       ├── LivenessResultContentView+Result.swift
│       ├── LivenessResultContentView.swift
│       ├── LivenessResultView.swift
│       ├── RootView.swift
│       ├── StartSessionView+PresentationState.swift
│       ├── StartSessionView.swift
│       └── StartSessionViewModel.swift
├── HostApp.xcodeproj
│   ├── project.pbxproj
│   ├── project.xcworkspace
│   │   ├── contents.xcworkspacedata
│   │   ├── xcshareddata
│   │   │   ├── IDEWorkspaceChecks.plist
│   │   │   └── swiftpm
│   │   │       ├── Package.resolved
│   │   │       └── configuration
│   │   └── xcuserdata
│   │       └── juanmagil.xcuserdatad
│   │           └── UserInterfaceState.xcuserstate
│   └── xcshareddata
│       └── xcschemes
│           └── HostApp.xcscheme
├── HostAppUITests
│   ├── HostAppUITests.swift
│   └── HostAppUITestsLaunchTests.swift
├── README.md
├── amplify
│   ├── cli.json
│   ├── generated
│   │   └── models
│   └── team-provider-info.json
├── amplifyconfiguration.json
└── awsconfiguration.json

Could you help me solve the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions