def get_auth_token(api, service_account):
  """Returns an access token for the service account."""
  cmd = [
    '/opt/infra-tools/authutil',
    'token',
    '-service-account-json',
    '/creds/service_accounts/service-account-%s.json' % service_account
  ]

  result = api.step(
      'Get auth token', cmd,
      stdout=api.raw_io.output(),
      step_test_data=lambda: api.raw_io.test_api.stream_output('ya29.foobar'))
  return result.stdout.strip()