0

我已經與谷歌日曆工作谷歌的例子。我的應用程序很好,直到他們最近更改了API。我發現他們的文檔有點壓倒性,並不是很有用。我用這個example.net和谷歌身份驗證

我收到以下錯誤

類型的未處理的異常: System.InvalidOperationException」發生在Google.Apis.Auth.dll

附加信息:至少有一個客戶端機密(已安裝或Web)

我不知道客戶的祕密是什麼或他們在說什麼。我搜索了這個短語,沒有任何信息會回來。什麼是客戶端,我該如何設置?

這是代碼行我得到錯誤。

credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
        GoogleClientSecrets.Load(stream).Secrets, scopes, "user", CancellationToken.None, 
        New FileDataStore("CalendarSample")).Result 

我有他們爲我設置的json文件,它似乎正在閱讀它。我相信我應該修改那個文件,但是我找不到有關它的確切說明。

任何幫助將是偉大的。我最終會做的只是添加和刪除谷歌日曆中的條目。

謝謝

+0

您是否嘗試過並獲得解決方案? –

回答

0

我打算假設你在這裏使用Oauth2。使用金塊包Google.Apis.Calendar.v3 Client Library

string clientId = "";//From Google Developer console https://console.developers.google.com 
string clientSecret = "";//From Google Developer console https://console.developers.google.com 
string userName = ""// A string used to identify a user. 
string[] scopes = new string[] { 
    CalendarService.Scope.Calendar, // Manage your calendars 
    CalendarService.Scope.CalendarReadonly // View your Calendars 
}; 

// here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData% 
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { 
     ClientId = clientId, ClientSecret = clientSecret 
    }, scopes, userName, CancellationToken.None, new FileDataStore("Daimto.GoogleCalendar.Auth.Store")).Result; 

一旦你驗證,那麼您可以使用創建日曆服務來訪問谷歌日曆

// Create the service. 
    CalendarService service = new CalendarService(new BaseClientService.Initializer() { 
     HttpClientInitializer = credential, 
     ApplicationName = "Calendar API Sample", 
    }); 

代碼從RIP處理

的基本代碼來驗證谷歌日曆教程Google Calendar API with C#本教程保持最新。

+0

我從來沒有得到答案。 –

+0

你試過這個嗎? – DaImTo