Skip to content

Commit 64489df

Browse files
committed
PR feedback
1 parent c32748b commit 64489df

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

googleapis_auth/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.2.0-wip
2+
3+
- Added `quotaProject` support to existing credentials classes
4+
(`ServiceAccountCredentials`, `ClientViaServiceAccount`, `ClientFromFlow`).
5+
16
## 2.1.0
27

38
- `AuthClientSigningExtension`: Added `sign()` which accepts an optional

googleapis_auth/lib/src/oauth2_flows/base_flow.dart

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,27 @@ class _FlowClient extends AutoRefreshDelegatingClient {
4343
final BaseFlow _flow;
4444
final String? _quotaProject;
4545

46-
@override
47-
AccessCredentials credentials;
48-
Client _authClient;
46+
AccessCredentials _credentials;
47+
late Client _authClient;
4948

50-
_FlowClient(super.client, this.credentials, this._flow, this._quotaProject)
51-
: _authClient = authenticatedClient(
52-
client,
53-
credentials,
54-
quotaProject: _quotaProject,
55-
);
49+
_FlowClient(super.client, this._credentials, this._flow, this._quotaProject) {
50+
_authClient = _recreateClient(_credentials);
51+
}
52+
53+
@override
54+
AccessCredentials get credentials => _credentials;
5655

5756
@override
5857
Future<StreamedResponse> send(BaseRequest request) async {
59-
if (credentials.accessToken.hasExpired) {
58+
if (_credentials.accessToken.hasExpired) {
6059
final newCredentials = await _flow.run();
6160
notifyAboutNewCredentials(newCredentials);
62-
credentials = newCredentials;
63-
_authClient = authenticatedClient(
64-
baseClient,
65-
credentials,
66-
quotaProject: _quotaProject,
67-
);
61+
_credentials = newCredentials;
62+
_authClient = _recreateClient(newCredentials);
6863
}
6964
return _authClient.send(request);
7065
}
66+
67+
Client _recreateClient(AccessCredentials credentials) =>
68+
authenticatedClient(baseClient, credentials, quotaProject: _quotaProject);
7169
}

googleapis_auth/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: googleapis_auth
2-
version: 2.1.0
2+
version: 2.2.0-wip
33
description: Obtain Access credentials for Google services using OAuth 2.0
44
repository: https://github.com/google/googleapis.dart/tree/master/googleapis_auth
55

0 commit comments

Comments
 (0)