我已將我的asp.net應用程序從Google日曆V2遷移到V3測試版,但現在他們已經發布了新版本1.8.1.820的新DLL,請問任何人都可以在這方面幫助我,我該如何轉換。在我的V3 beta版本我是用下面的代碼從Google日曆v3測試版遷移到v3 1.8.1.820
private CalendarService CreateService(string token)
{
KeyValuePair<string, string> credentials = Common.Get3LOCredentials();
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
provider.ClientIdentifier = credentials.Key;
provider.ClientSecret = credentials.Value;
var auth = new Google.Apis.Authentication.OAuth2.OAuth2Authenticator<NativeApplicationClient>(provider, (p) => GetAuthorization(provider, token, credentials.Key, credentials.Value));
CalendarService service = new CalendarService(new BaseClientService.Initializer()
{
Authenticator = auth,
ApiKey = ConfigurationManager.AppSettings["APIkey"].ToString(),
GZipEnabled = false
});
provider = null;
return service;
}
正如有新的版本,他們沒有NativeApplicationClient類等多種功能,他們沒有。因此,如果任何人有,請給我提供一些文檔,因爲Google沒有爲ASP.NET開發人員提供良好的文檔。
這是我使用谷歌日曆的新版本的代碼: -
private CalendarService CreateService(string token)
{
GoogleAuthorizationCodeFlow flow = null;
var assembly = Assembly.GetExecutingAssembly();
KeyValuePair<string, string> credentials = Common.Get3LOCredentials();
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = credentials.Key, ClientSecret = credentials.Value }, new[] { "https://www.googleapis.com/auth/calendar" }, "user", CancellationToken.None, new FileDataStore("Calendar.Sample.Store")).Result;
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Calendar API Sample",
});
return service;
}
難道你不喜歡每個版本如何從最後一個重大突破變化。去Google! – Craig