2016-03-30 27 views
0

çözülemeyen. benim uygulama motoru uygulamasında. Ben Eclipse Luna kullanıyorum ve bu bağlantıdan öğretici izlemiştir: google-api-client-jackson2-1.16.0-rc.jar, appengine-gcs-client-0.5.jar, ve google-api-client-1.8.0-beta.jar ben maven repo indirildi Yapımın yolunu aşağıdaki jarfiles eklemiş https://developers.google.com/identity/sign-in/web/server-side-flow#step_7_exchange_the_authorization_code_for_an_access_tokentip com.google.api.client.json.JsonFactory Google Oturum Açma sunucu tarafı uygulaması için uygulamaya çalışıyorum

.

bir hata var ve bunu çözmek için başka ne bilmiyorum. Kodumda çift yıldız işaretleri ile işaretledim.

hata iletisi: The type com.google.api.client.json.JsonFactory cannot be resolved. It is indirectly referenced from required .class files.
Ben StackOverflow'daki benzer sorunlar aramış ama buldum cevap yok bu sorunu çözdü.

, bazı kimse bana acı ve bana yardım eder misiniz! Bu özellik dağıtımımı geciktiriyor. Şimdiden teşekkür ederim.

@Override 
protected void doPost(HttpServletRequest request, HttpServletResponse response) 
     throws ServletException, IOException { 

    // Set path to the Web application client_secret_*.json file you downloaded from the 
    // Google Developers Console: https://console.developers.google.com/apis/credentials?project=_ 
    // You can also find your Web application client ID and client secret from the 
    // console and specify them directly when you create the GoogleAuthorizationCodeTokenRequest 
    // object. 
    ServletContext context = getServletContext(); 
    String CLIENT_SECRET_FILE = context.getRealPath("/WEB-INF/client/client_secret.json");  

    // Exchange auth code for access token 
    GoogleClientSecrets clientSecrets = 
     **GoogleClientSecrets.load(
      JacksonFactory.getDefaultInstance(), new FileReader(CLIENT_SECRET_FILE));** 
    GoogleTokenResponse tokenResponse = 
       new GoogleAuthorizationCodeTokenRequest(
        new NetHttpTransport(), 
        JacksonFactory.getDefaultInstance(), 
        "https://www.googleapis.com/oauth2/v4/token", 
        clientSecrets.getDetails().getClientId(), 
        clientSecrets.getDetails().getClientSecret(), 
        authCode, 
        REDIRECT_URI) // Specify the same redirect URI that you use with your web 
           // app. If you don't have a web version of your app, you can 
           // specify an empty string. 
        .execute(); 

    String accessToken = tokenResponse.getAccessToken(); 

    // Use access token to call API 
    GoogleCredential credential = new GoogleCredential().setAccessToken(accessToken); 
    Drive drive = 
     new Drive.Builder(new NetHttpTransport(), JacksonFactory.getDefaultInstance(), credential) 
      .setApplicationName("Auth Code Exchange Demo") 
      .build(); 
    File file = drive.files().get("appfolder").execute(); 

    // Get profile info from ID token 
    GoogleIdToken idToken = tokenResponse.parseIdToken(); 
    GoogleIdToken.Payload payload = idToken.getPayload(); 
    String userId = payload.getSubject(); // Use this value as a key to identify a user. 
    String email = payload.getEmail(); 
    boolean emailVerified = Boolean.valueOf(payload.getEmailVerified()); 
    String name = (String) payload.get("name"); 
    String pictureUrl = (String) payload.get("picture"); 
    String locale = (String) payload.get("locale"); 
    String familyName = (String) payload.get("family_name"); 
    String givenName = (String) payload.get("given_name");  

} 
+0

tarihinde HTTP İstemcisi Kitaplığı eksik? – jarmod

+0

Evet ben sadece inşa yoluna (google-http-istemci jackson2-1.21.0.jar) bunu eklemiş, ben maven indirmek. – NOBLES

cevap

0

Sana denpendencies indirmek olduğunu varsayalım ama kullanım maven kalmaz; i sorun Maven'in otomatik olarak dolaylı bağımlılıkları giderir olduğunu düşünüyorum, ama sen haven't bunları çözmek.

Eğer http-istemci kitaplığı ihtiyaç jsonFactory google's kullanmak istiyorsanız.

Burada indirebilirsiniz:

http://repo2.maven.org/maven2/com/google/http-client/google-http-client-jackson/

İlgili konular