3

我是 Google API 和基于 Web 的编程的新手,所以请原谅我的普遍无知。我正在尝试使用 Google Admin Audit API,但没有找到一个示例,说明如何进行调用以获取 ClientID 以便能够进行需要 CustomerID 的 Google API 调用之一——比如管理员审计。我已经运行了其他简单的示例,例如检索任务列表等,但问题是这些类型的调用不需要您使用客户 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

   }

我错过了什么吗?

4

1 回答 1

1

有一种简单的方法可以通过 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。
于 2013-05-22T17:21:50.957 回答