Skip to content

Commit dfeea5f

Browse files
committed
🔀 Merged with main
1 parent 9569b2a commit dfeea5f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

lib/src/oauth_chopper.dart

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,23 @@ class OAuthChopper {
5555
/// See [OAuthStorage] for more information.
5656
final OAuthStorage _storage;
5757

58-
/// Provide a custom [http.Client] which will be passed to [oauth2] and used for making new requests.
58+
/// Provide a custom [http.Client] which will be passed to [oauth2] and used
59+
/// for making new requests.
5960
final http.Client? httpClient;
6061

6162
/// Get stored [OAuthToken].
6263
Future<OAuthToken?> get token async {
6364
final credentialsJson = await _storage.fetchCredentials();
64-
return credentialsJson != null ? OAuthToken.fromJson(credentialsJson) : null;
65+
return credentialsJson != null
66+
? OAuthToken.fromJson(credentialsJson)
67+
: null;
6568
}
6669

6770
/// Provides an [OAuthAuthenticator] instance.
6871
/// The authenticator can throw exceptions when OAuth authentication fails.
6972
/// If [onError] is provided exceptions will be passed to [onError] and not be
7073
/// thrown.
7174
OAuthAuthenticator authenticator({
72-
/// When provided [onError] handles exceptions if thrown.
7375
OnErrorCallback? onError,
7476
}) =>
7577
OAuthAuthenticator(this, onError);
@@ -80,9 +82,9 @@ class OAuthChopper {
8082
/// Tries to refresh the available credentials and returns a new [OAuthToken]
8183
/// instance.
8284
/// Throws an exception when refreshing fails. If the exception is a
83-
/// [AuthorizationException] it clears the storage.
84-
/// See [Credentials.refresh]
85-
Future<OAuthToken?> refresh() async {
85+
/// [oauth2.AuthorizationException] it clears the storage.
86+
/// See [oauth2.Credentials.refresh]
87+
Future<OAuthToken?> refresh() async {
8688
final credentialsJson = await _storage.fetchCredentials();
8789
if (credentialsJson == null) return null;
8890
final credentials = oauth2.Credentials.fromJson(credentialsJson);
@@ -110,7 +112,11 @@ class OAuthChopper {
110112
/// Throws an exception if the grant fails.
111113
Future<OAuthToken> requestGrant(OAuthGrant grant) async {
112114
final credentials = await grant.handle(
113-
authorizationEndpoint, identifier, secret, httpClient,);
115+
authorizationEndpoint,
116+
identifier,
117+
secret,
118+
httpClient,
119+
);
114120

115121
await _storage.saveCredentials(credentials);
116122

0 commit comments

Comments
 (0)