oauth2 icon indicating copy to clipboard operation
oauth2 copied to clipboard

Login with Firefox

Open markbeij opened this issue 7 months ago • 1 comments

I have an app that uses oauth2 for login. On Android with Chrome as the default browser everything works as expected. When Firefox is your default browser however, it does not work. I use lanchUrl to open the login page and then wait untill the login is finished,

Code:

await launchUrl(
  loginUri,
  mode: LaunchMode.inAppBrowserView,
  webOnlyWindowName: '_self',
);

final incomingUri = await _appLinks.uriLinkStream.first;

client = await grant.handleAuthorizationResponse(
  incomingUri.queryParameters,
);

Relevant dependencies:

oauth2: ^2.0.2
url_launcher: ^6.2.1
app_links: ^3.4.5

After login, the app look like it restarts and comes up with a new login screen. For Chrome however the app gets resumed and I can store the access token and have a happy life.

Chrome

I/flutter ( 3127): appstate = AppLifecycleState.inactive
I/flutter ( 3127): appstate = AppLifecycleState.hidden
I/flutter ( 3127): appstate = AppLifecycleState.paused //After this, the login screen shows
I/flutter ( 3127): appstate = AppLifecycleState.hidden
I/flutter ( 3127): appstate = AppLifecycleState.inactive
I/flutter ( 3127): appstate = AppLifecycleState.resumed //After this, I can require an access token

Firefox

I/flutter ( 3697): appstate = AppLifecycleState.inactive
I/flutter ( 3697): appstate = AppLifecycleState.hidden
I/flutter ( 3697): appstate = AppLifecycleState.paused //After this, the login screen shows
I/flutter ( 3697): appstate = AppLifecycleState.inactive
I/flutter ( 3697): appstate = AppLifecycleState.hidden
I/flutter ( 3697): appstate = AppLifecycleState.paused //After this, the login screen shows

This doesn't seem the perfect place to ask this question, but someone has any tips.

markbeij avatar Jan 16 '24 10:01 markbeij