authClientFromAccessToken function

AuthClient authClientFromAccessToken(
  1. String token,
  2. List<String> scopes
)

Create AuthClient in case we only have an access token without the full credentials json. It's currently the case for Chrmoium LUCI bots.

Implementation

AuthClient authClientFromAccessToken(String token, List<String> scopes) {
  final DateTime anHourLater = DateTime.now().add(const Duration(hours: 1));
  final AccessToken accessToken =
      AccessToken('Bearer', token, anHourLater.toUtc());
  final AccessCredentials accessCredentials =
      AccessCredentials(accessToken, null, scopes);
  return authenticatedClient(Client(), accessCredentials);
}