1

Google 캘린더 V2에서 V3 Beta로 마이 asp.net 응용 프로그램을 마이 그 레이션했지만 이제는 1.8.1.820 버전의 새 DLL을 릴리스했습니다. 이런 점에서 나를 도우십시오. 나는 어떻게 개종 할 수 있습니까? 내 V3 베타 버전에 나는 그들이 NativeApplicationClient 클래스와 그들이 가지고 있지 않은 많은 기능이없는이 새로운 버전에서와 마찬가지로 코드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; 
} 

이하로 사용되었다. 따라서 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; 
} 
+0

각 릴리스의 마지막 변경 내용이 얼마나 중대하게 변경되었는지는 모르겠습니까? Go Google! – Craig

답변

0

우선 캘린더 API의 베타 버전이 아니며, 그것은 여기에 사용할 수 - -이 https://www.nuget.org/packages/Google.Apis.Calendar.v3/ :

이 내가 사용하고 구글 캘린더의 새로운 버전에 대한 코드입니다.

라이브러리는 지난 몇 개월 동안 베타 버전으로 출시되었으며 우리는 품질을 향상시키고 DotNetOpenAuth의 종속성을 제거하기 위해 열심히 노력하고 있습니다. 공지 블로그 (http://google-api-dotnet-client.blogspot.com/)를 살펴보면 모든 변경 사항이 설명되어 있습니다.

릴리스 1.8.1부터는 라이브러리가 GA (General Availability)에 도달했기 때문에 호환되지 않는 변경 사항이 없을 것입니다. 모든 OAuth 2.0 설명서는 https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth에 있습니다. 이 페이지를보고 거기에 누락 된 것이 있으면 알려주십시오. 특히 ASP.NET sample 또는 ASP.NET MVC code snippet에서 볼 수 있습니다.

+0

답장을 보내 주셔서 감사합니다. 나는이 부분을 시도했지만 "하나 이상의 예외"예외가 발생했습니다 위의 코드에서 위의 코드에서 CalendarService.Scope.Calendar를 null로 가져 오는 중입니다. 왜 이것을 null로 가져 오는지 확신 할 수 없습니다. 어디서 처음으로 인증을 받았는지 액세스 토큰을 지정해야하는 이유는 어디에서 토큰을 지정하는지 알 수 없었기 때문입니다. –

+0

Google 개발자가 언급 한 코드는 설치된 애플리케이션 용이지만 웹 애플리케이션에 통합되어 있다고 생각합니다. 모든 요청에서 AccessToken을 지정해야하므로 요청시 API를 사용하여 AccessToken을 지정할 수 있습니다. 나는 그것을 조사했지만 오래된 코드 만 얻었습니다. –