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
53 stars 54 forks source link

Issue prompting for authentication on OSX with Chrome as default browser #13

Closed Jack64 closed 1 year ago

Jack64 commented 2 years ago

Describe the bug

This is a re-post of https://github.com/LinusU/flutter_web_auth/issues/136 .

When using flutter_web_auth v0.4.1 (or flutter_web_auth_2 on v1.1.2) on Darwin OSX (12.5.1) targets that have the default browser set to Chrome (Version 105.0.5195.102 (Official Build) (x86_64)), the authentication prompt opens and closes immediately afterwards, causing a PlatformException. If the default browser is set to Safari, the authentication flows work as expected.

To Reproduce

Steps to reproduce the behavior:

  1. Set Chrome as default browser in OSX
  2. Start the authentication flow with the default browser (Chrome), using flutter_web_auth v0.4.1
  3. See the chrome window open and immediately close
  4. Stack trace:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(EUNKNOWN, The operation couldn’t be completed. (com.apple.AuthenticationServices.WebAuthenticationSession error 3.), null, null)
#0      StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:653
#1      MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:296
<asynchronous suspension>
#2      FlutterWebAuth2MethodChannel.authenticate
package:flutter_web_auth_2_platform_interface/flutter_web_auth_2_method_channel.dart:14
<asynchronous suspension>
#3      auth2

Expected behavior

The Chrome window should have opened on the correct URL, instead of not opening at all (when Chrome is already open) or opening on the "Chrome Profile Selection Page".

Screenshots

N/A

Device (please complete the following information!)

Additional context

N/A

ThexXTURBOXx commented 2 years ago

Wow, Apple is really causing many problems (as always lol)... According to the documentation this means that the context was invalid. And I think the context being meant is this one. It is also very nice to see that Apple does not care about such issues as seen here since noone responded to some guy having the exact same problem :) Enough about the Apple-rant - alas I do not own any Apple-device, so I am unable to debug this any further. But if someone else is willing to do this, he is of course free to do so. Thanks for the detailed bug report btw!

ThexXTURBOXx commented 2 years ago

I tagged this PR as being part of Hacktoberfest. So, if someone is able to fix and properly test this issue, he is one step closer to completing Hacktoberfest 2022 :)

Jack64 commented 2 years ago

Thanks for the quick feedback, however it is unfortunate that this is the status quo.

I'm unsure if this is an Apple issue or a Chrome issue.

Just for the sake of testing this a bit further, I downloaded Firefox and ran the same scenario... it is handled differently: when I set firefox as my default browser, the ASWebAuthenticationSession pop-up requests that you open the link with Safari, exactly that same as if Safari were the default browser. Perhaps this is more a Chrome issue rather than an Apple issue and this information might help whoever picks this up.

In any case, here's another instance of the same issue reported to Apple to which they did not respond :)

Knupper commented 2 years ago

I have tested it now multiple times with the newest 2.0.2 under mac os 13 and with chrome 107 and it works as it should. Can you may test it again with the newest version of this package?

ThexXTURBOXx commented 1 year ago

Closing this due to inactivity