【问题标题】:Google Admin Audit api - how do I get the CustomerID in C#Google Admin Audit api - 如何在 C# 中获取 CustomerID
【发布时间】:2012-09-18 13:57:16
【问题描述】:

我是 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

   }

我错过了什么吗?

【问题讨论】:

    标签: c# google-admin-audit-api


    【解决方案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。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-02
      • 2020-01-09
      • 1970-01-01
      • 1970-01-01
      • 2014-10-09
      • 2013-04-28
      • 2021-02-15
      • 1970-01-01
      相关资源
      最近更新 更多