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

Unable to Capture Redirect URLs with 'http' or 'https' CallbackUrlScheme on iOS without user interaction #65

Closed neokree closed 1 month ago

neokree commented 1 year ago

Describe the bug

When using this library with Universal Links on iOS to login into a service, the link is opened in the browser if the user is already logged in.

To Reproduce

Steps to reproduce the behavior:

  1. Setup Universal Links in example app and custom domain (and verify they are valid from iOS Settings -> Developer -> Universal Link)
  2. Edit the example app connection html page to include this snippet:
    <p>Redirecting in 3 seconds...</p>
    <script>
        setTimeout(function() {
            window.location.href = 'https://your.domain.com/?token=balalalala';
        }, 3000); // 3000 milliseconds = 3 seconds
    </script>
  3. Run the example app, try to login and wait for 3 seconds
  4. The universal link is opened inside the browser instead of returning to the app

Expected behavior

When using a redirect to a universal link without user interaction, browser closes and app receives the callback

Device (please complete the following information!)

Additional context

This seems more like a bug of Safari, instead of this library's code (Read "Preparing Your App to Handle Universal Links" at https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html) Nevertheless I have lost 2 days trying to fix it so it seemed logic to me that this situation must be shared for future developers.

Checklist

rdunlocked18 commented 1 year ago

Any Update on this ?

ThexXTURBOXx commented 1 year ago

This looks like "Apple being Apple" again. I am unsure if this is a bug within this package or iOS or the backend since there is no way for me to test that (I don't own a apple device)

rdunlocked18 commented 1 year ago

This looks like "Apple being Apple" again. I am unsure if this is a bug within this package or iOS or the backend since there is no way for me to test that (I don't own a Apple device)

I am not able to redirect to the application. I have no setup for Universal Links also I am using localhost:3000/callback.html as a redirect URL. If you want to test anything on iOS I can help.

Can you tell me what should be

  1. Redirect URL :
  2. Callback Scheme For ios :

Currently, it shows a white page if I redirect with code on localhost:3000/callback.html, should this page be live .. in the sense should it load?

ThexXTURBOXx commented 1 year ago

This is a case of "RTFM", but I will help anyway: The redirect URL is the URL which serves the login page. The callback scheme is the URL scheme that is used for redirection to the app.

rdunlocked18 commented 1 year ago

This is a case of "RTFM", but I will help anyway: The redirect URL is the URL which serves the login page. The callback scheme is the URL scheme that is used for redirection to the app.

That thing is fine ! but what if I don't have universal links added ?

ThexXTURBOXx commented 1 year ago

This is the setup without universal links. If you want universal links, you need to some extra setup. Otherwise, everything works normally

Edit: Also, this issue is about universal links. If you have issues without them, you are better off filing a new issue

SunilKividor commented 6 months ago

@ThexXTURBOXx @rdunlocked18 Did you guys have any solution regrading redirection in IOS ?

SunilKividor commented 6 months ago

@ThexXTURBOXx I do not have the classes(FlutterWebAuth2Plugin.h,...) in my IOS folder. DO i need to add those three files too ?

rdunlocked18 commented 6 months ago

Nothing just add the same URL scheme in iOS, which is of Android, and also in info.plist...Add this from below & change the URL Scheme

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>$(url schema)</string>
        </array>
    </dict>
</array>
SunilKividor commented 6 months ago

@rdunlocked18 Do i need to add the scheme in this way if it is https ? - $https

SunilKividor commented 6 months ago

@rdunlocked18 if i use https as my url scheme , does the redirect link should be of valid domain ?