clientViaServiceAccount function
Future<AutoRefreshingAuthClient>
clientViaServiceAccount(
- ServiceAccountCredentials clientCredentials,
- List<
String> scopes, { - Client? baseClient,
Obtains oauth2 credentials and returns an authenticated HTTP client.
See obtainAccessCredentialsViaServiceAccount for specifics about the arguments used for obtaining access credentials.
HTTP requests made on the returned client will get an additional
Authorization
header with the AccessCredentials obtained.
Once the AccessCredentials expire, it will use it's refresh token
(if available) to obtain new credentials.
See autoRefreshingClient for more information.
If baseClient
is provided, all HTTP requests will be made with it.
Otherwise, a new Client
instance will be created.
The user is responsible for closing the returned HTTP Client
.
Closing the returned Client
will not close baseClient
.
Implementation
Future<AutoRefreshingAuthClient> clientViaServiceAccount(
ServiceAccountCredentials clientCredentials,
List<String> scopes, {
Client? baseClient,
}) async =>
await clientFromFlow(
(c) => JwtFlow(
clientCredentials.email,
clientCredentials.privateRSAKey,
clientCredentials.impersonatedUser,
scopes,
c,
),
baseClient: baseClient,
);