From 1491b2bda0ded850d005824bf2fc015157d31e05 Mon Sep 17 00:00:00 2001 From: Michael Bui <25263378+MaikuB@users.noreply.github.com> Date: Sun, 13 Oct 2024 13:37:28 +1100 Subject: [PATCH] added logic to recreate AuthorizationService objects if disposed but were needed --- flutter_appauth/CHANGELOG.md | 1 + .../flutterappauth/FlutterAppauthPlugin.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/flutter_appauth/CHANGELOG.md b/flutter_appauth/CHANGELOG.md index 2e6f8f2..a35eb66 100644 --- a/flutter_appauth/CHANGELOG.md +++ b/flutter_appauth/CHANGELOG.md @@ -1,6 +1,7 @@ ## [8.0.0-dev.4] * [Android] no functional changes but some code around dealing with `allowInsecureConnections` has been done in response to issue [554](https://github.com/MaikuB/flutter_appauth/issues/554) +* [Android] added logic to help with issues like [205](https://github.com/MaikuB/flutter_appauth/issues/205) where an app tries to refresh a token but the instances of `AuthorizationService` have been disposed ## [8.0.0-dev.3] diff --git a/flutter_appauth/android/src/main/java/io/crossingthestreams/flutterappauth/FlutterAppauthPlugin.java b/flutter_appauth/android/src/main/java/io/crossingthestreams/flutterappauth/FlutterAppauthPlugin.java index ed2acc9..d7d8a3a 100644 --- a/flutter_appauth/android/src/main/java/io/crossingthestreams/flutterappauth/FlutterAppauthPlugin.java +++ b/flutter_appauth/android/src/main/java/io/crossingthestreams/flutterappauth/FlutterAppauthPlugin.java @@ -579,6 +579,10 @@ private void performEndSessionRequest( } private AuthorizationService getAuthorizationService() { + if (insecureAuthorizationService == null || defaultAuthorizationService == null) { + // There have been some reported instances where the services have been disposed but they're still needed e.g. to refresh token + createAuthorizationServices(); + } AuthorizationService authorizationService = allowInsecureConnections ? insecureAuthorizationService : defaultAuthorizationService; return authorizationService;