Google Admin Audit api - how do I get the CustomerID in C#

1.2k Views Asked by At

I am new to the Google API and web based programming so excuse my general ignorance. I am trying to use the Google Admin Audit APIs and have not found an example of how to make the call to get the ClientID to be able to make one of the Google API calls that require the CustomerID - like Admin Auditing. I have run other simple examples like retrieving Tasks list etc but the issue is that these types of calls do not require you to use a Customer ID.

I have all the right includes as per other Google API examples plus Google.Apis.Audit.v1 required for auditing. I have enabled the provisioning API in my admin console and I have created a new client based project in the API console and also enabled the Audit API service for the project.

Here is generally what I am doing:

 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

   }

Am I missing something?

1

There are 1 best solutions below

0
On

There is an easy way to get the customerId through the API's explorer (no coding needed).

  1. Log onto the domain
  2. Go to: https://developers.google.com/apis-explorer/#s/reports/v1/reports.customerUsageReports.get?date=2013-05-18&_h=1&
  3. Authorize OAuth
  4. When you run the report, you'll see the customerId in the response.