LinusU / flutter_web_auth

Flutter plugin for authenticating a user with a web service
MIT License
198 stars 176 forks source link

Android - https schemas does not trigger intent after successful login. #52

Open akeblom opened 4 years ago

akeblom commented 4 years ago

When using "https" as android:scheme I do not get redirected back to my app after login. If I open the redirection url in chrome the app opens.

Runnign adb shell command works fine

adb shell am start -W -a android.intent.action.VIEW -d "https://myhost.here.com"

We are using https because when we are using a generic scheme users running Xiomi-devices do not get redirected back to the app.

final result = await FlutterWebAuth.authenticate(
          url: url,
          callbackUrlScheme: 'https');

AndroidManifest.xml

<activity android:name="com.linusu.flutter_web_auth.CallbackActivity">
      <intent-filter android:label="flutter_web_auth">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="https" android:host="myhost.here.com" />
      </intent-filter>
    </activity>
i10416 commented 3 years ago

I encountered this issue too. It seems that dialog asking user for which app to open the link blocks the redirect when uri scheme is http/https.

Users probably have to configure default app to open the link(https://myhost.here.com) and change Open supported links configuration from ask every time to open in this app before calling FlutterWebAuth.authenticate.

You can configure it at Settings > Apps & Notifications > Default Apps > Opening Links > your App.

This problem may be solved if you set <intent-filter android:autoVerify="true"> and provide Digital Asset Links at https://myhost.here.com/.well-known/assets-link.json in order to verify that the host you are trying to navigate is related with your app.

These links may be helpful. https://stackoverflow.com/questions/57904361/how-to-directly-land-to-the-app-without-asking-user-choice-in-android-deep-link https://developer.android.com/training/app-links/deep-linking https://developer.android.com/training/app-links/verify-site-associations