def main(argv):
  """A script to test Apps Security APIs: revoking oauth2 tokens."""
  flags = common_flags.ParseFlags(argv, 'Revoke tokens issued for a client id.',
                                  AddFlags)
  log_border = (40 * '-')
  log_utils.LogInfo('revoke_tokens_for_domain_clientid starting...\n%s'
                    % log_border)

  if flags.use_local_token_stats:
    stats_user_list = token_report_utils.GetUsersInDomain(
        token_report_utils.GetTokenStats(), flags.client_id)
  else:
    stats_user_list = []  # List of users with a token for an issue domain

  http = auth_helper.GetAuthorizedHttp(flags)
  apps_security_api = tokens_api.TokensApiWrapper(http)

  # The user list holds a tuple for each user of: email, id, full_name
  # (e.g. 'larry@altostrat.com', '000000000098938768732', 'Larry Summon').
  print PREFIX % 'Scanning domain users for %s...'
  for user in user_iterator.StartUserIterator(http, PREFIX, flags):
    user_email, _, _ = user
    # Skip revocation attempts if tokens not found in the latest report.
    if flags.use_local_token_stats and user_email not in stats_user_list:
      continue

    try:
      # NOTE: attempting to revoke a non-existent token causes no
      #       discernible output (no failure message or fail status).
      apps_security_api.DeleteToken(user_email, flags.client_id)
    except admin_api_tool_errors.AdminAPIToolTokenRequestError as e:
      # This suggests an unexpected response from the apps security api.
      # As much detail as possible is provided by the raiser.
      sys.stdout.write('%80s\r' % '')  # Clear the previous entry.
      sys.stdout.flush()
      log_utils.LogError(
          'Unable to revoke token for user %s and client_id %s.'
          % (user, flags.client_id), e)
      sys.exit(1)
    # If attempting to revoke tokens for the whole domain, do not print
    # confirmation because we're not sure which users actually had the tokens.
    if flags.use_local_token_stats:
      log_utils.LogInfo(
          'Successfully revoked token for user %s for client_id %s.'
          % (user_email, flags.client_id))
  log_utils.LogInfo('revoke_tokens_for_domain_clientid done.\n%s' % log_border)
  print 'Revocation details logged to: %s.' % log_utils.GetLogFileName()
  if not flags.use_local_token_stats:
    print 'NOTE: To save time, revocation is attempted for all domain users '
    print '      without checking in advance if a token was granted.  Because '
    print '      revocation returns no indication of actual token revocation, '
    print '      the actual clients of tokens revoked are not logged. If it '
    print '      is required to log the actual client ids of revoked tokens, '
    print '      run the gather token stats command and use '
    print '      --use_local_token_stats with this command. '
dataset/ETHPy150Open google/gfw-toolkit/toolkit/cmds/revoke_tokens_for_domain_clientid.py/main/swapped operands of `%`