@@ -55,21 +55,23 @@ class OAuthChopper {
55
55
/// See [OAuthStorage] for more information.
56
56
final OAuthStorage _storage;
57
57
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.
59
60
final http.Client ? httpClient;
60
61
61
62
/// Get stored [OAuthToken] .
62
63
Future <OAuthToken ?> get token async {
63
64
final credentialsJson = await _storage.fetchCredentials ();
64
- return credentialsJson != null ? OAuthToken .fromJson (credentialsJson) : null ;
65
+ return credentialsJson != null
66
+ ? OAuthToken .fromJson (credentialsJson)
67
+ : null ;
65
68
}
66
69
67
70
/// Provides an [OAuthAuthenticator] instance.
68
71
/// The authenticator can throw exceptions when OAuth authentication fails.
69
72
/// If [onError] is provided exceptions will be passed to [onError] and not be
70
73
/// thrown.
71
74
OAuthAuthenticator authenticator ({
72
- /// When provided [onError] handles exceptions if thrown.
73
75
OnErrorCallback ? onError,
74
76
}) =>
75
77
OAuthAuthenticator (this , onError);
@@ -80,9 +82,9 @@ class OAuthChopper {
80
82
/// Tries to refresh the available credentials and returns a new [OAuthToken]
81
83
/// instance.
82
84
/// 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 {
86
88
final credentialsJson = await _storage.fetchCredentials ();
87
89
if (credentialsJson == null ) return null ;
88
90
final credentials = oauth2.Credentials .fromJson (credentialsJson);
@@ -110,7 +112,11 @@ class OAuthChopper {
110
112
/// Throws an exception if the grant fails.
111
113
Future <OAuthToken > requestGrant (OAuthGrant grant) async {
112
114
final credentials = await grant.handle (
113
- authorizationEndpoint, identifier, secret, httpClient,);
115
+ authorizationEndpoint,
116
+ identifier,
117
+ secret,
118
+ httpClient,
119
+ );
114
120
115
121
await _storage.saveCredentials (credentials);
116
122
0 commit comments