aws-amplify / aws-sdk-android

AWS SDK for Android. For more information, see our web site:
https://docs.amplify.aws
Other
1.02k stars 548 forks source link

Cognito Hosted UI Sign Out Fails when Offline #2359

Open doc-rj-celltrak opened 3 years ago

doc-rj-celltrak commented 3 years ago

Describe the bug

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

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):

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

longthanhle91 commented 2 years ago

Hi, is there any update on this issue?

div5yesh commented 2 years ago

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.