flutter_appauth icon indicating copy to clipboard operation
flutter_appauth copied to clipboard

[flutter_appauth] Expose native exception type and code to the Flutter code

Open timnew opened this issue 3 years ago • 6 comments

An implementation for the issue https://github.com/MaikuB/flutter_appauth/issues/394

It employs a new code format: <existing code>:<domain/type>:<code>

This might need to be considered as Breaking Changes, as it breaks the code that checks code right now. But it can be easily fixed:

For existing code:

try { 
  // calling appauth
} on PlatformException catch(ex) {
  if (ex.code == "authorize_and_exchange_code_failed") {
    // handle error
  }
}

It can be upgraded as

try { 
  // calling appauth
} on PlatformException catch(ex) {
  if (ex.code.startsWith("authorize_and_exchange_code_failed:")) {
    // handle error
  }
}

For user cancelled the webview for auth, the error could be

  • iOS: authorize_and_exchange_code_failed:org.openid.appauth.general:-3
  • Android: authorize_and_exchange_code_failed:GENERAL_ERROR:1

timnew avatar Dec 14 '22 07:12 timnew

Hey @timnew, would it be possible to change this PR so the there's now a new Exception class that gets thrown by the plugin? The thinking behind this is to avoid having consumers of the plugin fiddling with the string and have the native error code by the native SDKs be behind a separate property. This would also be in-line with what I read recently in https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#platform-exception-handling that IMO makes sense to adopt in this situation. This would look something like defining a new class in the platform interface package for the exception whose structure is similar to that defined in https://api.flutter.dev/flutter/services/PlatformException-class.html but have a nullable error property named something like nativeAppAuthSDKErrorCode whose purpose is to hold the error codes thrown by the native AppAuth Android/iOS SDKs. Let me know what you think

MaikuB avatar Feb 05 '23 03:02 MaikuB

@MaikuB I'll try to do it asap! Got a bit snowed by the daily work

timnew avatar Feb 15 '23 01:02 timnew

@timnew any updates on this MR? Could you look into it?

neokree avatar May 29 '23 10:05 neokree

When is this going to be completed/merged? Its been close to 4 months since there were some changes requested.

MewanWA avatar Jul 17 '23 06:07 MewanWA

https://docs.github.com/articles/what-are-the-different-access-permissions

prabuddaFernando avatar Jul 17 '23 06:07 prabuddaFernando

Reminder that a good number of people working on open source software do so via their spare time. If you have need for something then you can look at carrying on the work yourself via your own fork

MaikuB avatar Jul 17 '23 07:07 MaikuB

Closing this in favour of #509 that has been merged in

MaikuB avatar Aug 04 '24 23:08 MaikuB