Skip to content

Commit 86d351d

Browse files
author
Bas de Vaan
authored
Merge pull request #9 from DutchCodingCompany/feature/improve_refreshing
Improve token refreshing
2 parents 8eecb62 + 6f03d65 commit 86d351d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/src/oauth_chopper.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class OAuthChopper {
6868
OAuthInterceptor get interceptor => OAuthInterceptor(this);
6969

7070
/// Tries to refresh the available credentials and returns a new [OAuthToken] instance.
71-
/// Throws an exception when refreshing fails. See [Credentials.refresh]
71+
/// Throws an exception when refreshing fails. If the exception is a [AuthorizationException] it clears the storage.
72+
/// See [Credentials.refresh]
7273
Future<OAuthToken?> refresh() async {
7374
final credentialsJson = await _storage.fetchCredentials();
7475
if (credentialsJson == null) return null;
@@ -78,7 +79,7 @@ class OAuthChopper {
7879
await credentials.refresh(identifier: identifier, secret: secret);
7980
await _storage.saveCredentials(newCredentials.toJson());
8081
return OAuthToken.fromCredentials(newCredentials);
81-
} catch (e) {
82+
} on AuthorizationException {
8283
_storage.clear();
8384
rethrow;
8485
}

0 commit comments

Comments
 (0)