2012-09-18 26 views
3

我是新的谷歌API和基於Web編程,所以原諒我一般的無知。我正在嘗試使用Google管理審覈API,但沒有找到如何使呼叫獲得ClientID以便能夠進行需要CustomerID的Google API調用之一的示例 - 例如管理審覈。我已經運行了其他簡單的例子,如檢索任務列表等,但問題是這些類型的調用不要求您使用客戶ID。谷歌管理員審計API - 我如何獲得C#中的客戶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 

    } 

我這麼想嗎?

回答