flutter_appauth icon indicating copy to clipboard operation
flutter_appauth copied to clipboard

Is it possible to save authorization session on ios?

Open postflow opened this issue 2 years ago • 3 comments

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?

postflow avatar May 23 '22 07:05 postflow

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

MaikuB avatar May 31 '22 09:05 MaikuB

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

postflow avatar Jun 01 '22 06:06 postflow

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

MaikuB avatar Jun 01 '22 06:06 MaikuB

@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?

devsideal avatar Feb 22 '23 12:02 devsideal