Amplify-android: Amplify.signInWithWebUI not prompting login page for new user after calling Amplify.signOut

Created on 10 Jul 2020  路  6Comments  路  Source: aws-amplify/amplify-android

Describe the bug
The first time I call Amplify.signInWithWebUI, the login screen shows up.

However, it doesn't show up again if I call sign-out, and then call sign-in for a second time, to prepare for a new user.

Steps to reproduce the behavior:

  1. Call Amplify.signInWithWebUI.
  2. Enter user credentials (login succeeds, and navigates back to the app).
  3. Call Amplify.signOut (The callback is retrieved)
Amplify.Auth.signOut(
    () -> Log.d("AuthQuickstart", "signedout"),
    error -> Log.d("AuthQuickstart", error.toString())
);
  1. Call Amplify.signInWithWebUI. This time, the user will _not_ be prompted with a login screen, but instead retrieves the callback with isSignInComplete=true.

Expected behavior

  1. CallAmplify.signInWithWebUI
  2. Enter user credentials (login succeeds, navigates back to the app)
  3. Call Amplify.signOut (callback retrieved)
  4. Call Amplify.signInWithWebUI
  5. User will be prompted with login screen

Note - Also tried doing a global sign-out, i.e.:

Amplify.Auth.signOut(
    AuthSignOutOptions.builder().globalSignOut(true).build(),
    () -> Log.i("AuthQuickstart", "Signed out globally"),
    error -> Log.e("AuthQuickstart", error.toString())
);

but this produces an error:

getTokens does not support retrieving tokens while signed-out

Additional context
While calling Amplify.signInWithWebUI, user is not prompted with login screen but result is retrieved indicating isSignInComplete=true. But after that, if a call is made to:

Amplify.Auth.fetchAuthSession(
    result -> Log.i("AmplifyQuickstart", result.toString()),
    error -> Log.e("AmplifyQuickstart", error.toString())
);

I see isSignedIn=false. If it returned true for isSignInComplete in the first step, then why it is returning false while retrieving tokens?

See below for full response from both the calls.

* Amplify.signInWithWebUI response*

AuthSignInResult {
  isSignInComplete = true, nextStep = AuthNextSignInStep {
    signInStep = DONE, additionalInfo = {
      provider = cognito - idp.us - east - 2. amazonaws.com / us - east - 2 _jxxxxxxxx,
      token = <token value>
    }, codeDeliveryDetails = null
  }
}

* Amplify.Auth.fetchAuthSession response *

AWSCognitoAuthSession {
  isSignedIn = false, awsCredentials = AuthSessionResult {
    value = null, error = AmplifyException {
      message = You are currently signed out., cause = null, recoverySuggestion = Please sign in and reattempt the operation.
    }, type = FAILURE
  }, userSub = 'AuthSessionResult{value=null, error=AmplifyException {message=You are currently signed out., cause=null, recoverySuggestion=Please sign in and reattempt the operation.}, type=FAILURE}', identityId = 'AuthSessionResult{value=null, error=AmplifyException {message=You are currently signed out., cause=null, recoverySuggestion=Please sign in and reattempt the operation.}, type=FAILURE}', userPoolTokens = 'AuthSessionResult{value=null, error=AmplifyException {message=You are currently signed out., cause=null, recoverySuggestion=Please sign in and reattempt the operation.}, type=FAILURE}'
}
Auth Bug Clarification Needed Closing Soon

All 6 comments

Adding more context as I have been working with Flori on the issue. This one uses the same backend as mentioned in https://github.com/aws-amplify/amplify-ios/issues/630#issuecomment-656662644... not sure if issue is specific to signing out for a federated sign in.

Hey, sorry about this - it is a bug with the current sign out which we have addressed in #570 and will be out in the next release shortly.

Just released the fix to this so if you update to v1.1.0 it should resolve it!

I updated my SDK to

 implementation 'com.amplifyframework:core:1.1.0'
 implementation 'com.amplifyframework:aws-auth-cognito:1.0.0' 

My login and logout is working fine. But I still have issue with login screen. The user is not prompted with login screen after log out. Instead, user will be logged in automatically using old username and password (happening because of cookies.) Every-time, we have to wipe the cookies to get login screen.

Could you post your relevant code snippets?

I updated my SDK to

 implementation 'com.amplifyframework:core:1.1.0'
 implementation 'com.amplifyframework:aws-auth-cognito:1.0.0' 

It looks like you updated core, but not aws-auth-cognito? David's fix is in 1.1.0 of the auth lib, not of the core lib.

Let us know, either way. Please re-open if this is still an issue with 1.1.x.

Was this page helpful?
0 / 5 - 0 ratings