MaikuB / flutter_appauth

A Flutter wrapper for AppAuth iOS and Android SDKs
270 stars 243 forks source link

Is it possible to save authorization session on ios? #334

Closed postflow closed 1 year ago

postflow commented 2 years ago

I go through the authorization on ios and go to the application safely. When opening a web page through url_launcher:

launch(url, forceSafariVC: true)

from inside my application on ios, it asks me for authorization again.

On android, authorization session is saved and I can open a web page without getting a login and password input window

Is it possible to save authorization state on ios?

MaikuB commented 2 years ago

Apple's APIs are different than Android and they're different operating systems so comparing behaviour on both platforms may not suitable. This plugin uses another SDK to do the heavy lifting so you'd need to look into how it works underneath the hood for more info on ask there. I believe it's to do with what's documented at https://developer.apple.com/documentation/authenticationservices/authenticating_a_user_through_a_web_service#overview where the following note is mentioned

When not using an ephemeral session, all cookies except session cookies are available to the browser.

This means session cookies aren't shared and is to do with how's Apple APIs work so outside the control of any plugin

postflow commented 2 years ago

I was able to solve my problem with plugin: https://pub.dev/packages/flutter_web_auth this plugin use ASWebAuthenticationSession under the hood.

MaikuB commented 2 years ago

That's interesting as the AppAuth iOS SDK does as well. See https://github.com/openid/AppAuth-iOS/blob/98ed5e15ceedcacc0b3fd6c3521a22411acc2212/Source/AppAuth/iOS/OIDExternalUserAgentIOS.m#L91 . Therefore, I'd expect the same behaviour

devsideal commented 1 year ago

@postflow @MaikuB I'm also getting exact same issue in iOS only,

After successfully Authentication via keycloak, When i open a web page through

await launchUrl( Uri.parse(url), mode: LaunchMode.externalApplication )

It asks me to login again.

@postflow as you suggested I tried with "flutter_web_auth" package also, But getting the same behavior. How it's working for you? Can you please give any suggestions If I'm missing anything?