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
51 stars 50 forks source link

Redirection to app does not work #101

Open ElvinMammadov opened 5 months ago

ElvinMammadov commented 5 months ago

Description

Redirection to app does not work. I am using Google sign in authentication process and after successfully sign in it redirects to callback url and opens it. But I don't need it. I need to close browser after successfull sign in process. This is redirect url https://zygomorphic-carola-td-money.koyeb.app/callback. Despite the fact I added all necessery fields in Android Manifest it does not redirect to app. What is wrong in my implementation ? Maybe I miss something ?

Minimal Reproduction

Steps to reproduce the behaviour:

  1. Use the following code:

     action: () async {
                        final String result =
                            await FlutterWebAuth2.authenticate(
                          url:
                              "https://zygomorphic-carola-td-money.koyeb.app/v1/client/auth",
                          callbackUrlScheme:
                              "https",
                        );
    
                        print('result is $result');
    
                        final token =
                            Uri.parse(result).queryParameters['state'];
                        print('token is $token');
                      },
  2. Android Manifest activity
    <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="https"
                    android:host="zygomorphic-carola-td-money.koyeb.app"
                    android:pathPrefix="/callback"
                     />
            </intent-filter>
        </activity>

Exception or Error

There is not error, just redirection does not work properly.

Expected Behaviour

After receiving redirected url, browser has to close and should return to app.

Screenshots

No response

Additional context

No response

Device

Xiaomi Redmi Note 9

OS

Android

Browser

Chrome

Flutter version

3.13.8

flutter_web_auth_2 version

3.1.1

Checklist

ThexXTURBOXx commented 5 months ago

There was already a similar issue at some point: #56 Sadly, this seems to be related to some issues within Android and I would always advise to use a custom scheme instead of http/https as it seems to be the only solution currently.

goj1 commented 4 months ago

@ElvinMammadov something worked for you?

Painwraith commented 5 hours ago

I guess this is still broken on Android? Thanks for everyones hard work creating the package.

ThexXTURBOXx commented 5 hours ago

@Painwraith The troubleshooting guide has been expanded since last time, also due to #113 - maybe the solutions from there helps?