LinusU / flutter_web_auth

Flutter plugin for authenticating a user with a web service
MIT License
197 stars 169 forks source link

Web auth shows two options to the user, app name and flutter_web_auth #121

Closed maysamsh closed 1 year ago

maysamsh commented 2 years ago

My app supports deep links and also uses this package for web auth. there is a confusing action sheet shown to the user before opening the browser:

screenshot

This is my intent:

<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" android:exported="true">
           <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="myappscheme" />
           </intent-filter>
       </activity>

Is there any way to open the browser right away instead of showing this confusing UI?

biscottis commented 2 years ago

Simply use a different scheme for either your deep links or flutter_web_auth. Yeah, it's more work to maintain another scheme but that's the workaround.

vinhhoangdo commented 2 years ago

I stuck with this issue. Does everyone have any solutions?

bartcone-fulfilld commented 2 years ago

@vinhhoangdo do you happen to have appAuthRedirectScheme defined with the same scheme name in manifestPlaceholders (build.gradle)? If not, what does your AndroidManifest.xml look like? Do you have two or more intents with the same <data android:scheme=<scheme> />?

vinhhoangdo commented 2 years ago

Yeah thank dude @bartcone-fulfilld, I will check the scheme name in manifestPlaceholders. In the AndroidManifest.xml: For this, I defined some intents like:

<application>
.....
  <activity >
   .......
    <intent-filter>
       <action android:name="android.intent.action.VIEW" />
       <category android:name="android.intent.category.DEFAULT" />
       <category android:name="android.intent.category.BROWSABLE" />
       <data android:scheme="myScheme" />
    </intent-filter>
  </activity>
  <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="myScheme" />
                 <data android:host="login" />
             </intent-filter>
  </activity>
  <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
</application>

And now, If I install the app and click on the Login button, it will show the dialog with two options! I will update more info about manifestPlaceholders (build.gradle)..! Thank you!

vinhhoangdo commented 2 years ago

Hi @bartcone-fulfilld, I am back to work and checking the manifestPlaceholders. So it does not define in the build.gradle. Could you tell me what am I supposed to do now man?

bartcone-fulfilld commented 2 years ago

@vinhhoangdo you have two <data android:scheme="myScheme" /> in that manifest file. Make them different and then try (by different I mean change the myScheme part).

vinhhoangdo commented 2 years ago

@bartcone-fulfilld yeah, I see. Is there any way to keep both schemes the same? Or both of them should differ from each other.

LinusU commented 1 year ago

@vinhhoangdo the schemes need to be different in order for the setup to work, since the callback must open the flutter_web_auth activity in order to receive the callback. I would suggest appending something like -auth to your callback scheme for the authentication.

Please also see the new troubleshooting section of the readme: https://github.com/LinusU/flutter_web_auth#troubleshooting

Let me know if you are still having problem!