flutter_web_auth_2 icon indicating copy to clipboard operation
flutter_web_auth_2 copied to clipboard

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

Open nateshmbhat opened this issue 10 months ago • 1 comments

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

  • [X] I have read and followed the entire troubleshooting guide and it has not provided the solution I need.
  • [X] I have provided all the information I can.

nateshmbhat avatar Apr 24 '24 07:04 nateshmbhat

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

ThexXTURBOXx avatar Apr 24 '24 07:04 ThexXTURBOXx

Stale issue; closing due to inactivity

ThexXTURBOXx avatar May 04 '24 18:05 ThexXTURBOXx

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

adrian-moisa avatar May 22 '24 08:05 adrian-moisa

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.

ThexXTURBOXx avatar May 22 '24 08:05 ThexXTURBOXx