2012-09-23 2 views
4

Google에서 단계별로 수행하는 configuration instructions을 따르고 있습니다.하지만 어떤 이유 때문에 가져올 패키지가 없습니다. 내 응용 프로그램을 찾을 수없는 패키지는 (또는 라인 내 IDE 대해 불평) :Google 캘린더 Java 앱을 설치하는 방법

import com.google.api.client.auth.oauth2.draft10.AccessTokenResponse; 
import com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAccessProtectedResource; 
import com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAccessTokenRequest.GoogleAuthorizationCodeGrant; 
import com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAuthorizationRequestUrl; 

나는이를 보유하고있는 항아리를 찾을 수 없습니다. 내 클래스 패스에 다음이 포함되어 있습니다.

//The Google Calendar Client API: 
google-api-services-calendar-v3-rev16-1.8.0-beta.jar 

//And of course the Google API Core: 
commons-logging-1.1.1.jar 
google-api-client-1.11.0-beta.jar 
google-api-client-1.11.0-beta.jar.properties 
google-api-client-android-1.11.0-beta.jar 
google-api-client-android-1.11.0-beta.jar.properties 
google-api-client-android2-1.11.0-beta.jar 
google-api-client-android2-1.11.0-beta.jar.properties 
google-api-client-appengine-1.11.0-beta.jar 
google-api-client-java6-1.11.0-beta.jar 
google-http-client-1.11.0-beta.jar 
google-http-client-1.11.0-beta.jar.properties 
google-http-client-android-1.11.0-beta.jar 
google-http-client-android-1.11.0-beta.jar.properties 
google-http-client-android2-1.11.0-beta.jar 
google-http-client-android2-1.11.0-beta.jar.properties 
google-http-client-android3-1.11.0-beta.jar 
google-http-client-android3-1.11.0-beta.jar.properties 
google-http-client-appengine-1.11.0-beta.jar 
google-http-client-gson-1.11.0-beta.jar 
google-http-client-gson-1.11.0-beta.jar.properties 
google-http-client-jackson-1.11.0-beta.jar 
google-http-client-jackson-1.11.0-beta.jar.properties 
google-http-client-jackson2-1.11.0-beta.jar 
google-http-client-jackson2-1.11.0-beta.jar.properties 
google-oauth-client-1.11.0-beta.jar 
google-oauth-client-1.11.0-beta.jar.properties 
google-oauth-client-appengine-1.11.0-beta.jar 
google-oauth-client-java6-1.11.0-beta.jar 
google-oauth-client-jetty-1.11.0-beta.jar 
google-oauth-client-servlet-1.11.0-beta.jar 
gson-2.1.jar 
gson-2.1.jar.properties 
guava-11.0.1.jar 
guava-11.0.1.jar.properties 
httpclient-4.0.3.jar 
httpcore-4.0.1.jar 
jackson-core-2.0.5.jar 
jackson-core-2.0.5.jar.properties 
jackson-core-asl-1.9.9.jar 
jackson-core-asl-1.9.9.jar.properties 
jdo2-api-2.3-eb.jar 
jetty-6.1.26.jar 
jetty-util-6.1.26.jar 
jsr305-1.3.9.jar 
transaction-api-1.1.jar 
xpp3-1.1.4c.jar 

실종 됐는지 확실하지 않지만 튜토리얼을 계속 진행하려면 라이브러리가 필요합니다. 더 많은 정보가 필요하면 그것을 기꺼이 제공 할 것입니다. 나는 Google Calendar API에 관해서는 초보자입니다. 어떤 도움을 주셔서 감사합니다! 감사!

+0

Google은 draft10이 더 이상 사용되지 않을 것이라고 생각했지만, Google에서 예제를 업데이트 할 수있는 것을 보지 못했습니다. – MadProgrammer

+0

[draft 10] (http://code.google.com/p/google-api) -java-client/wiki/OAuth2Draft10) 및 [OAuth 2.0] (http://code.google.com/p/google-api-java-client/wiki/OAuth2) – MadProgrammer

+0

@MadProgrammer, 나는 그것이 사용되지 않을 것으로 생각합니다. 다른 방법을 사용하는 또 다른 예를 알고 있습니까? – kentcdodds

답변

12

불행히도 현재 Google은 the Java configuration source code을 업데이트하지 않았습니다. 당신은 그 수업이 필요 없으며 그들의 의견에서 다른 사람들이 지적했듯이, 그들은 비난 받는다.

대체은 "draft10"수입에 의해 그런 다음

import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; 
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; 
import com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse; 
import com.google.api.services.calendar.CalendarScopes; 

, 인증 코드를 대체 (코멘트에서 "1 단계 : 권한 부여 ->"이후)에 의해 : 내가 가진

GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
       httpTransport, jsonFactory, clientId, clientSecret, 
      Arrays.asList(CalendarScopes.CALENDAR)).setAccessType("online") 
       .setApprovalPrompt("auto").build(); 

String url = flow.newAuthorizationUrl().setRedirectUri(redirectUrl).build(); 
System.out.println("Please open the following URL in your browser then type the authorization code:"); 

System.out.println(" " + url); 
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
String code = br.readLine(); 

GoogleTokenResponse response = flow.newTokenRequest(code) 
       .setRedirectUri(redirectUrl).execute(); 
GoogleCredential credential = new GoogleCredential() 
       .setFromTokenResponse(response); 

// Create a new authorized API client 
Calendar service = new Calendar.Builder(httpTransport, jsonFactory, 
       credential).build(); 

동일한 문제가 발생하여 the drive sample code이 최신 상태 인 것으로 나타났습니다. 내 길을 짐작하고 일하게 만들었습니다. "인증 코드 흐름"은 here으로 설명됩니다.