2012-11-12 5 views
3

사용자의 프로필 데이터를 인증 및 가져 오려고하는데 오류가 발생했습니다. 제안 해주세요.Google 크롬에서 프로필 정보 가져 오기

// Generate the URL to which we will direct users 
    String authorizeUrl = new GoogleAuthorizationRequestUrl(CLIENT_ID, 
      CALLBACK_URL, SCOPE).build(); 
    System.out.println("Paste this url in your browser: " + authorizeUrl); 

    // Wait for the authorization code 
    System.out.println("Type the code you received here: "); 
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); 
    String authorizationCode = in.readLine(); 

    // Exchange for an access and refresh token 
    GoogleAuthorizationCodeGrant authRequest = new GoogleAuthorizationCodeGrant(
      TRANSPORT, JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, 
      authorizationCode, CALLBACK_URL); 
    authRequest.useBasicAuthorization = false; 

    AccessTokenResponse authResponse = authRequest.execute(); 
    String accessToken = authResponse.accessToken; 

    GoogleAccessProtectedResource requestInitializer = new GoogleAccessProtectedResource(
      accessToken, TRANSPORT, JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, 
      authResponse.refreshToken); 

     // Set up the main Google+ class 
    Plus plus = new Plus(TRANSPORT, requestInitializer,JSON_FACTORY); 

    // Make a request to access your profile and display it to console 
    Person profile = plus.people.get("me").execute(); 
    System.out.println("ID: " + profile.getId()); 
    System.out.println("Name: " + profile.getDisplayName()); 
    System.out.println("Image URL: " + profile.getImage().getUrl()); 
    System.out.println("Profile URL: " + profile.getUrl()); 

오류는 다음과 같습니다 - 스레드

예외는 "주요"java.lang.IllegalAccessError가 : 클래스 com.google에서 필드 com.google.api.client.http.HttpRequest.method에 액세스하려고. com.google.api.client.googleapis.MethodOverride (com.google.api.client.googleapis.MethodOverride.overrideThisMethod (MethodOverride.java:99) , com.google.api.client.googleapis.MethodOverride.intercept (MethodOverride.java:87)) at com.google.api.services.plus.ApiClient.buildHttpRequest (ApiClient.java:251) at com.google.api.services.plus.Plus $ RemoteRequest.execute (Plus.java:1055) (com.google.api.services.plus.Plus) $ People $ Get.executeUnparsed (Plus.java:991) at com.google.api.services.plus.Plus $ People $ Get.execute (Plus.java : 976) at com.googleplus.test.TestAuth2.main (TestAuth2.java:64)

+0

이 특정 문제와 관련이 없지만 [OAuth 2.0 초안 10]을 사용하고 있습니다. [* deprecated *] (http://code.google.com/p/google-api-java-client/wiki/OAuth2Draft10) – alfasin

답변

관련 문제