c# - Google Admin Audit api - 如何在 C# 中获取 CustomerID

标签 c# google-admin-audit-api

我是 Google API 和基于网络的编程的新手,所以请原谅我的普遍无知。我正在尝试使用 Google Admin Audit API,但没有找到如何调用以获取 ClientID 以便能够进行需要 CustomerID 的 Google API 调用之一的示例 - 例如 Admin Auditing。我已经运行了其他简单示例,例如检索任务列表等,但问题是这些类型的调用不需要您使用客户 ID。

我拥有所有权利,包括按照其他 Google API 示例加上审计所需的 Google.Apis.Audit.v1。我在我的管理控制台中启用了配置 API,并在 API 控制台中创建了一个新的基于客户端的项目,还为该项目启用了审计 API 服务。

这通常是我正在做的事情:

 public IAuthenticator GetServiceInterface()
   {
      ClientProvider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
      ClientProvider.ClientIdentifier = "MY_CLIENT_ID";
      ClientProvider.ClientSecret = "MY_CLIENT_SECRET";
      IAuthenticator IAuth = new OAuth2Authenticator<NativeApplicationClient>(ClientProvider, GetAuthorization);
      return IAuth;

   }


   private IAuthorizationState GetAuthorization(NativeApplicationClient client)
   {
      string[] ScopeList = new string[2] { "https://apps-apis.google.com/a/feeds/policies/", "https://www.googleapis.com/auth/apps/reporting/audit.readonly" };
      IAuthorizationState IAuthState = new AuthorizationState(ScopeList);
      IAuthState = AuthorizationMgr.RequestNativeAuthorization(client, ScopeList);
      return IAuthState;

   }


   public void GoogleAuditTest()
   {
      //Get a Audit Service Interface
      AuditService AuService = new AuditService( GetServiceInterface() );

      ????????????????????????????
      ...How do I get the CustomerID required by the audit service calls to list activities, etc

   }

我错过了什么吗?

最佳答案

有一种通过 API 的资源管理器获取 customerId 的简单方法(无需编码)。

  1. 登录域
  2. 转到: https://developers.google.com/apis-explorer/#s/reports/v1/reports.customerUsageReports.get?date=2013-05-18&_h=1&
  3. 授权OAuth
  4. 运行报告时,您会在响应中看到 customerId。

关于c# - Google Admin Audit api - 如何在 C# 中获取 CustomerID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12478509/

相关文章:

c# - WPF MVVM 应用程序中多个异步调用期间的单个错误弹出

c# - MigrationHistory 表中的模型列是什么?

c# - 为什么使用参数时会出现 SQL 解析错误?

google-admin-audit-api - Google 电子邮件日志搜索 API

c# - WebClient 和多个网络适配器

C# 开源项目命名空间