Aws-sdk-ios: getTokens Completion Handler not getting called after token expiry

Created on 8 Jan 2020  路  7Comments  路  Source: aws-amplify/aws-sdk-ios

public func getTokens(_ completionHandler: @escaping (Tokens?, Error?) -> Void)
The completion handler doesn't get called in the AWS iOS SDK when we call this method after refreshToken expires.. Please advice how to proceed.

I can confirm that user is Signed in as AWSCognitoService.client.isSignedIn is true.

The getTokens method claims to return a new id token if the one available is expired. Or send a notification to re-sign in.

It does return us a new idToken when one expires and if there is a valid refreshToken.
BUT it neither returns a new idToken nor throws an error when refreshToken expires.

Environment:
-SDK Versions used in the App

  • AWSAuthCore (2.12.3):

    • AWSCore (= 2.12.3)

    • AWSCognitoIdentityProvider (2.12.3):

    • AWSCognitoIdentityProviderASF (= 1.0.1)

    • AWSCore (= 2.12.3)

    • AWSCognitoIdentityProviderASF (1.0.1)

    • AWSCore (2.12.3)

    • AWSMobileClient (2.12.3):

    • AWSAuthCore (= 2.12.3)

    • AWSCognitoIdentityProvider (= 2.12.3)

    • Dependency Manager: Cocoapods

    • Swift Version : 5.0

Device Information :

  • Device: All devices and simulators
  • iOS Version: 11.4 and above

Additional context
The refresh token expiry is set to 24 hours at the backend. So when we relaunch the app after a day, the app is stuck on getTokens API.

mobile client question requesting info

All 7 comments

Hi. This issue is blocking the release of our iOS that is scheduled in a weeks time. Do you have any ETA on this please?

We're facing with this issue too.

Hi @spandana-batchu

Thank you for reaching out.
Are you using AWSMobileClient.signIn to signin the user? If yes, you should track the state of user session and call AWSMobileClient.signIn again if the user state changed to signedOut. getToken call will wait until the user signed in.

I am facing the same issue. I'm originally coming from this thread: https://github.com/aws-amplify/aws-sdk-ios/issues/2208

When I call AWSMobileClient.default().isSignedIn it returns True also when I call AWSMobileClient.default().currentUserState it says signedIn

@royjit Thanks for the reply.
We added the user state listener and logging out the user when the state is signedOutUserPoolsTokenInvalid which was what was causing the getTokens completion to never get called.

@spandana-batchu Glad you were able to resolve the issue. @velociraptor111 Can you review @spandana-batchu's answer and if that doesn't help, please open a new issue with the specific details of your case, including steps to repro, SDK versions, etc.

I'm closing this issue since the original issue is solved by the user state change listener.

@palpatim https://github.com/aws-amplify/aws-sdk-ios/issues/2400#issue-591292441
We have another issue that came up. signedOutUserPoolsTokenInvalid is getting called sooner than expected. Even though expiry is set to 24 hours, this gets called after 60 mins after we added "migrationEnabled" flag in the configuration.

Was this page helpful?
0 / 5 - 0 ratings