aws-sdk-android icon indicating copy to clipboard operation
aws-sdk-android copied to clipboard

Cognito Hosted UI Sign Out Fails when Offline

Open doc-rj-celltrak opened this issue 4 years ago • 2 comments

Describe the bug

When offline and signed in via hosted UI (showSignIn), signing out fails.

  • When signing out with invalidateTokens=true, it leaves the user with a "no internet" error on the web page.

  • When signing out with invalidateTokens=false, the user is automatically signed in (without credentials) the next time showSignIn is called. The same thing happens when plain signOut with no parameters is called.

Neither of these paths allows for signing out while offline. This issue was recently fixed for iOS with new APIs -- https://github.com/aws-amplify/aws-sdk-ios/issues/3141 https://github.com/aws-amplify/amplify-ios/pull/1037

To Reproduce

  1. Sign in using hosted UI via showSignIn().
  2. Put android device in airplane mode.
  3. Try signing out via signOut with invalidateTokens=true. The user will be stuck on the web page with an error.
  4. Try signing out via signOut with invalidateTokens=false. Next time showSignIn() is called, the last user will be automatically signed in without entering credentials.
    AWSMobileClient.getInstance().showSignIn(this.activity, signInUIOptions, object : Callback<UserStateDetails> {  // ...
    // ...
    val signOutOptions: SignOutOptions = SignOutOptions.builder()
        .invalidateTokens(isInvalidateTokens)
        .signOutGlobally(isSignOutGlobally)
        .build()

    AWSMobileClient.getInstance().signOut(signOutOptions, object : Callback<Void> {. // ...

Which AWS service(s) are affected?

Cognito

Expected behavior

When signed in with hosted UI, the user should be able to sign out when the device is offline (no network connectivity). Currently, the user is unable to sign out properly.

Screenshots

Screenshot_1613147782

Environment Information (please complete the following information):

  • AWS Android SDK Version: 2.19.1
  • Device: Pixel 3a or any device
  • Android Version: 11
  • Specific to simulators: No

Additional context

This issue was recently fixed in the iOS SDK with new APIs, and offline sign out is now possible -- https://github.com/aws-amplify/aws-sdk-ios/issues/3141 https://github.com/aws-amplify/amplify-ios/pull/1037

doc-rj-celltrak avatar Feb 12 '21 17:02 doc-rj-celltrak

Hi, is there any update on this issue?

longthanhle91 avatar Oct 26 '21 05:10 longthanhle91

To signout of the hostedUI, device needs to be online. Calling local signout will clear tokens, but hostedUI signout requires calling Cognito logout endpoint. Unlike iOS, Android custom tabs does not support private sessions due to which signout has to rely on successful hostedUI request.

div5yesh avatar Apr 21 '22 01:04 div5yesh