MaikuB / flutter_appauth

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

Authorization failes if the orientation changes on android #319

Closed pfistnerm closed 2 years ago

pfistnerm commented 2 years ago

The Authorization fails with the following exception if the orientation changes after the process: PlatformException(authorize_and_exchange_code_failed, Failed to authorize: [error: null, description: User cancelled flow], null, null)

Steps to reproduce:

The app will run in landscape and change to portrait during the authentication. When the authorization was successful, the orientation will change back to landscape and the authorizeAndExchangeCode() method will fail with the said exception.

This behavior was only reproduceable on multiple physical devices but not on a emulator.

MaikuB commented 2 years ago

This isn't an issue for the plugin and relates to how Android apps work in general. You'll need to do some research into this e.g. https://developer.android.com/guide/topics/resources/runtime-changes

pfistnerm commented 2 years ago

Do you have a suggestion on how to deal with this issue? I know that those configuration changes need to be handled but I think the plugin should handle this since it's the one throwing the error. I'm not able to prevent that in any way from outside of the plugin.

MaikuB commented 2 years ago

The plugin throwing the error doesn't mean it's an issue for the plugin. As for suggestion, please refer to the docs mentioned. If you look at the docs, it mentions how this is app level configuration to begin with and the former maintainer of the SDK has stated it's the responsibility of the app too https://github.com/openid/AppAuth-Android/issues/104#issuecomment-244440818