[SOLVED] After login with Google the webview still open and redirecting back to a new login
- 0
- Flutter
my emulator is running android version 13 though (api version 33). im not sure if that makes a difference
[✓] Flutter (Channel stable, 3.7.6, on macOS 13.1 22C65 darwin-arm64, locale en-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.76.0)
[✓] Connected device (3 available)
[✓] HTTP Host Availability```
I've upgraded the android sdk version to last available. The error still persists.
I am testing in a real device with Android 13, and emulator with Android 13. Everything is updated. I think my last option now is uninstall everything.
I sent to you in DM a video using the playground project. With everything updated. It's very strange the same code works fine in your mac and not in mine. It might be some cache here.
My android sdk version is 33. I'm not sure if that makes a difference.
Also, I wonder if the memory of the emulator makes a difference...let me see how much memory I allocated
I have 3gb ram and 30gb disk space in the emulator. I also tested with Android SDK 33.0.0
@dlohani have you experienced this? Where if you tap back on Android, you're taken back to the oauth WebView?
Sometimes I have a similar experience
@squallsama Were you able to fix it? Or just happens and stop happening?
No. It happens so rarely, so I just accepted it.
I don't think I have
@Steven @fernandoxlr do sent me the server details if you want me to test it out
I couldn't reproduce on my server
Last resort would be hacking the SDK to pass true for prefer ephemeral here: https://github.com/appwrite/sdk-for-flutter/blob/f8480fdeecfb23782bd5b33d0e2a7db44fc8c391/lib/src/client_io.dart#L316
@Steven I added "preferEphemeral: true", the same issue happened, but now I was able to do a workaround.
As my MainActivity is android:launchMode="singleInstance"
. I've created a method channel to open my main activity back. Because the preferEphemeral
create the activity with FLAG_ACTIVITY_NO_HISTORY
when I open my MainActivity back, the webview is closed.
So in dart, I just call the native method right after login.
MainActivity.java
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine){
GeneratedPluginRegistrant.registerWith(flutterEngine);
super.configureFlutterEngine(flutterEngine);
new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
.setMethodCallHandler(
(call, result) -> {
if (call.method.contentEquals("backToApp")){
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
result.success(null);
}
}
);
}
Flutter part:
var platform = MethodChannel('my_platform/channel');
platform.invokeMethod('backToApp');
[SOLVED] After login with Google the webview still open and redirecting back to a new login
@Steven it's solved, but I had to modify the Appwrite SDK, what do you think about expose preferEphemeral to account.createOAuth2Session()
?
Actually, I think you can set the property in your manifest file too...have you tried that? https://stackoverflow.com/questions/11836080/how-does-androidnohistory-true-work
No, because android:noHistory="true"
I have to put in the activity that will be launched. But who launches the activity is the FlutterWebAuth2 plugin
Oh you mean it has to go in the WebView activity and not the flutter web auth 2 activity?
Yes. First I edited AppWrite sdk to use preferEphemeral, then AppWrite sdk calls FlutterWebAuth2 authenticate method that puts NO_HISTORY to the activity of webview there. So in my project's AndroidManifest file I haven't access to that activity.
@dlohani do you think it would make sense to always pass true to prefer ephemeral?
I think supabase does this. So I never faced the same issue with supabase auth(they are using web auth also)
yes, I'll have a PR
Wowo, i want to use google auth in production... Maybe i should wait to the fix XD
Recommended threads
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...
- [SOLVED] OAuth With Google & Flutter
Hi all, I'm trying to sign in with google and it all goes swimmingly until the call back. I get a new user created on the appwrite dashboard however the flutte...