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

Mac OS error: found nil while unwrapping an Optional value => lost Connection to Device => App Closes #30

Closed redinsch closed 1 year ago

redinsch commented 1 year ago

Describe the bug

I was trying to use the flutter_web_auth_2 Plugin for my Flutter App, on IOS and Web it works Great, but on my Mac, wenn the _platform.authenticate Method is Called the App Closes Instantly and in the Debug Output are the following Messages: flutter_web_auth_2/FlutterWebAuth2Plugin.swift:39: Fatal error: Unexpectedly found nil while unwrapping an Optional value Lost connection to device. Exited

To Reproduce

Steps to reproduce the behavior: the Parameters are:

url: https://domain.auth0.com/authorize?response_type=code&client_id=clientID&redirect_uri=workingRedirectURI&state=state&code_challenge=codeChallenge&code_challenge_method=S256

callbackUrlScheme: workingRedirectScheme

preferEphemeral: false

redirectOriginOverride: null

I found nothing Helpful in the Issues or the Troubleshoot guide so I Think its a Bug?

redinsch commented 1 year ago

of course the values in the url are replaced but the url is working

ThexXTURBOXx commented 1 year ago

I am pretty sure that keyWindow must be the field that is nil. Is your issue maybe mentioned here somwhere? https://stackoverflow.com/questions/32418959/nsapplication-keywindow-is-nil-during-applicationdidfinishlaunching Sadly, I don't have any apple devices to debug this, so if someone is able to reproduce or fix this issue, please go ahead and create a PR! :)

Adam-Langley commented 1 year ago

I've submitted a PR to correctly fix this issue on MacOS in developers own use of this library. Attribution to the flutter_inappwebview project for an example on how to do it correctly.