Skip to content

[ AWSCognitoIdentityProvider] Error Domain=com.amazonaws.AWSCognitoIdentityProviderErrorDomain Code=-1000 #5549

@PrinceDev920

Description

@PrinceDev920

Issue description:
Once user is logged in and after the token expires, it is not getting refreshed. It was working a week before.

Steps to reproduce the behavior:

1. Installed the latest AWSCognitoIdentityProvider and AWSCore from pods
2. Login with a valid user
3. After token expired try to generate new token using -(AWSTask<AWSCognitoIdentityUserSession*> *) getSession
4. Function call on task based return a failure result with error Domain=com.amazonaws.AWSCognitoIdentityProviderErrorDomain Code=-1000 .

Observed Behavior
User is authenticated and logged in. After some days on call of getSession() method defined in AWSCognitoIdentityProvider gives error with domain com.amazonaws.AWSCognitoIdentityProviderErrorDomain and code -1000

Expected Behavior
If user is once authenticated and logged in after token expires, it should get refreshed on call of getSession() method

Code Snippet

// 1. Setting of user pool in the init

func setUserPool() {
        let config = userDefaultsManager.getConfigDetails()
        let serviceConfiguration = AWSServiceConfiguration(
            region: AWSRegionType.regionTypeForString(regionString: config.cloudRegion), // Set your region
            credentialsProvider: nil
        )

        let poolConfiguration = AWSCognitoIdentityUserPoolConfiguration(
            clientId: config.appClientId,
            clientSecret: nil,
            poolId: config.userPoolId
        )

        AWSCognitoIdentityUserPool.register(
            with: serviceConfiguration,
            userPoolConfiguration: poolConfiguration,
            forKey: "UserPool"
        )

        userPool = AWSCognitoIdentityUserPool(forKey: "UserPool")
        currentUser = userPool?.currentUser()
    }

// During login delegate was set to the AWSCognitoIdentityUserPool
//Also there is no issue during login process either with password or otp

  user.getSession().continueWith { task in

                    if let error = task.error {   // since error is throw by the sdk
                        if !isInternetError(error as NSError) { // and if its not due to internet
                            self.userAuthSession.sessionInvalid() // causes my user to logout
                        }
                        continuation.resume(returning: "")
                        return nil
                    }

                    if let session = task.result {
                        Task {
                            await myCognitoSession.setSession(session)
                            continuation.resume(returning: session.idToken?.tokenString ?? "")
                        }
                    } else {
                        continuation.resume(returning: "")
                    }

                    return nil
                }

Device Information (please complete the following information):
Most of iOS phones with iOS version 16.0 above

Metadata

Metadata

Assignees

No one assigned

    Labels

    authbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions