Open metalwings opened 10 months ago
Playing around with the android:launchMode
in https://gitlab.com/metalwings/appwrite-flutter-oauth2-demo/-/blob/main/android/app/src/main/AndroidManifest.xml?ref_type=heads#L9 as suggest by @stnguyen90 didn't help.
Tested on iOS. Everything works there, because the sign-in window behavior is different.
Also found a new clue: For some reason, the browser window "Sign in with Google" is closed automatically as soon as I try to switch to another app.
https://github.com/appwrite/sdk-for-flutter/assets/6256062/97e719c2-1f23-40f0-849d-db91f00a3d2d
This behavior can be reproduced on different physical Android devices and on emulated devices as well.
flutter_web_auth_2
String provider = "google";
String projectId = "<YOUR PROJECT ID HERE>";
String host = "https://cloud.appwrite.io/v1";
String url = "$host/account/sessions/oauth2/$provider?project=$projectId";
try {
await FlutterWebAuth2.authenticate(
url:url,
callbackUrlScheme: "appwrite-callback-$projectId");
await widget.account.createOAuth2Session(provider: provider);
} catch (e) {
print("Do nothing or handle exception, because the login was not successful");
}
👟 Reproduction steps
Requirements
Reproduction
createOAuth2Session(provider: "google")
Further information
Article how to add Google 2FA to your account: https://support.google.com/accounts/answer/185839
I've created a minimal reproduction repository: https://gitlab.com/metalwings/appwrite-flutter-oauth2-demo
In my case the default "is this you?" screen is automatically shown by android as soon as I try to login into my account.
👍 Expected behavior
Switching to any authenticator app doesn't break the login flow. Users should be able to switch to other app (in my case the default android auth by google, check my 2FA Code (or press "that's me") and login after I've completed the 2FA flow
👎 Actual Behavior
The login flow is cancelled due to loss of app focus. An exception is thrown:
🎲 Appwrite version
Version 2.0.x Appwrite Cloud SDK Version 11
💻 Operating system
Linux
🧱 Your Environment
Problem can be reproduced in the appwrite cloud version
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?