ThexXTURBOXx / flutter_web_auth_2

Flutter plugin for authenticating a user with a web service
https://pub.dev/packages/flutter_web_auth_2
MIT License
53 stars 54 forks source link

[Bug]: browser window doesn't close on Android even sso redirection is successful #106

Closed nateshmbhat closed 6 months ago

nateshmbhat commented 6 months ago

Description

Currently, i'm doing sso login using this library and after the login, the webpage redirects to the following intent url which is handled inside the app. the authenticate function resolves fine and i see the callback url in my dart logs.

final callbackUrl = await FlutterWebAuth2.authenticate(
      url: ssoUrl,
      callbackUrlScheme: 'sso',
    );

Issue : The browser window does not close and is still focused even after the authenticate promise has resolved.

Minimal Reproduction

final callbackUrl = await FlutterWebAuth2.authenticate(
      url: ssoUrl,
      callbackUrlScheme: 'sso',
    );
 <activity
      android:name="com.linusu.flutter_web_auth_2.CallbackActivity"
      android:exported="true">
      <intent-filter android:label="flutter_web_auth_2">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="sso" />
      </intent-filter>
    </activity>

Exception or Error

There's no error log

Expected Behaviour

The web browser should close and app should come into focus

Screenshots

No response

Additional context

No response

Device

Oneplus 7

OS

Android 12

Browser

Chrome

Flutter version

3.19.5

flutter_web_auth_2 version

3.1.1

Checklist

ThexXTURBOXx commented 6 months ago

Please try out with the latest 4.x pre-release and also try to set intentFlags within FlutterWebAuth2Options to ephemeralIntentFlags

ThexXTURBOXx commented 6 months ago

Stale issue; closing due to inactivity

adrian-moisa commented 5 months ago

Is there a reason why ephemeral intent flags are not active by default?

ThexXTURBOXx commented 5 months ago

It causes problems with intents that are being launched during the authentication session. For example, when opening MFA apps like Authy to copy OTPs, the custom tab is closed if it is ephemeral. I have not yet found a solution which makes the custom tab act as "ephemeral", but at the same time allows MFA apps (or even password managers like Bitwarden) to open without terminating the custom tab.