clientViaServiceAccount function

Future<AutoRefreshingAuthClient> clientViaServiceAccount(
  1. ServiceAccountCredentials clientCredentials,
  2. List<String> scopes, {
  3. Client? baseClient,
})

Obtains oauth2 credentials and returns an authenticated HTTP client.

See obtainAccessCredentialsViaServiceAccount for specifics about the arguments used for obtaining access credentials.

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,
    );