amplify-flutter
amplify-flutter copied to clipboard
SignOut doesn't invalidates the browser cache in OAuth Google[External federated identity provider]
Describe the bug When a user installs the app, he is able to choose an acc. between different google accounts for signup. But when the user is logged out and tries again to login, SignWithWebUI doesn't let the user choose another google account, it just automatically logs in with the previous account.
Code for login:
SignInResult res = await Amplify.Auth.signInWithWebUI(
provider: AuthProvider.google);
print("success login");
Code for log out:
await Amplify.Auth.signOut();
To Reproduce Steps to reproduce the behavior:
- call signInWithWebUI, select one google account
- call SignOut
- Again sign in, will not prompt for account selection, also #118 needs to be solved.
Expected behavior After signout, it should somehow invalidate the browser cache. Another new login should be prompted for google account selection. For IOS, it is working expected. Platform Amplify Flutter currently supports iOS and Android. This issue is reproducible in (check all that apply): [x] Android [] iOS
Hi @hackrx - sorry you are facing this issue. It appears to be a bug in the Android library which is currently under investigation: https://github.com/aws-amplify/amplify-android/issues/1287. We will be following the issue there and will incorporate their fix ASAP once it's available.
do you guys have any update?
Guys, do we have a forecast for a solution?
Hi guys, unfortunately, we do not have any updates on this issue. We will be closely following the Android issue linked above, though, and will prioritize an update as soon as the issue is resolved on their end.
It is odd that you claim this is just an android issue, as this also happens on iOS.
@hackrx Hi, Did you find a way to fix this issue?
Hi all, amplify-android maintainers suggested a workaround.
Hi all, I am also facing the same issue.
When I create a new Android emulator and sign in with google, I will be able to enter username and password. But I stuck at the this page
I need to restart my app and click the sign in with google button again, I am not prompted with the google's enter credential page, though I could not get current user from Cognito with Amplify.Auth.getCurrentUser()
. I am still signed in with the user I use above.
@ben-the-developer - what happens when you call getCurrentUser()?
Sorry @Jordan-Nelson, just realise I typed an extra not
. It should be I need to restart my app and click the sign in with google button again, I am not prompted with the google's enter credential page, though I could get current user from Cognito with Amplify.Auth.getCurrentUser().
@ben-the-developer - thanks for the update. I think the behavior you are seeing is consistent with the behavior described in this issue. If you are still signed into Google in your browser, you will be automatically signed in on the following attempt.
Thank you @Jordan-Nelson. I will try the walkaround mentioned above.
We recently released a new developer-preview version of amplify-flutter (amplify_flutter v1.0.0-next.0) that I believe will improve (but not completely resolve) this issue. The new version is a re-write of the auth library in dart, with added support for web and desktop, but also addresses several auth issue.
The behavior in the new version should be as follows:
- If you are not logged into any Google accounts in your default browser* you will be prompted to login to a Google account when using social sign in with Google.
- If you are logged into exactly one Google account in your default browser* you will not be given the choice of which account to use. You will be automatically logged in with that account.
- If you are logged into multiple Google accounts in your default browser* you will be given the choice of which of those accounts you want to use each time you sign in.
*The browser used for social sign in will be the default browser for the device on all platforms with the exception of on iOS which will always use Safari.
You can read more about the developer preview release in the blog post and docs. If you have a chance to try out this dev-preview version, please let us know if you have feedback.
In order to fully resolve this issue and present the account chooser screen each time, (even when the user is logged into exactly one account in their browser) the prompt parameter is required. This parameter is currently not supported by Cognito. Support for this in in their backlog, but I do not have a timeline when support will be added.
Thank you @Jordan-Nelson , that's very helpful. Let me try the new version.
Hello all - It appears we have two issues open tracking this. https://github.com/aws-amplify/amplify-flutter/issues/1528 appears to be for the same request. It looks like there may have been confusion as to whether or not this was a separate issue that was specific to Android. While there may be some platform inconsistencies, I believe the root issue is really the lack of support for the prompt
parameter as described above.
If you believe this issue is different than https://github.com/aws-amplify/amplify-flutter/issues/1528, please let me know. Otherwise I will close this one out and use https://github.com/aws-amplify/amplify-flutter/issues/1528 to track this request as it already captures the relevant info.
Apologies for the confusion.
Hi @Jordan-Nelson , thank you for sharing the new dev version. I tried the new dev version. As you mentioned,
- when I have no account signs in Chrome and it's the first time to sign in a user in my app, I will be prompted to sign in a new account in google web page.
- when I have one account signs in Chrome, my app always use this account without any prompt
- when I have two accounts sign in Chrome, I will be notified and it asks me to choose which account to sign in my app
One thing I found in the example that, previously, we need to create new activity named com.amplifyframework.auth.cognito.activities.HostedUIRedirectActivity
and put the intent-filter
in this activity. With the new version, HostedUIRedirectActivity
cannot be found any more and I need to move the intent-filter
in the MainActivity. Is it as expected?
Hello all - It appears we have two issues open tracking this. #1528 appears to be for the same request. It looks like there may have been confusion as to whether or not this was a separate issue that was specific to Android. While there may be some platform inconsistencies, I believe the root issue is really the lack of support for the
prompt
parameter as described above.If you believe this issue is different than #1528, please let me know. Otherwise I will close this one out and use #1528 to track this request as it already captures the relevant info.
Apologies for the confusion.
Hi @Jordan-Nelson , to me, I think my issue is the same as that in https://github.com/aws-amplify/amplify-flutter/issues/1528. I haven't tested in IOS so not sure what will happen in there.
Yes, this expected. You can see the difference in platform setup for hosted UI here. The docs now have the setup instructions for stable and developer preview. The setup is a little different for Android as you mentioned.
closing this issue as a duplicate of #1528
Hi all, amplify-android maintainers suggested a workaround.
could you please describe more detail how to address this workaround in flutter?