2014-05-08 14 views
5

Sono nuovo a Google Project e devo integrare Google Calendar e Google Task nel mio progetto. per questo sto rispondendo [https://developers.google.com/google-apps/calendar/instantiate][1]. Ho già aggiunto:Autorizzazione dell'API di Google Calendar Errore

servizi di Google Play come biblioteca google-API-servizi-calendar-v3-rev81-java-1.18.0-rc.

Ma sta mostrando errore "che il tipo com.google.api.client.auth.oauth2.draft10.AuthorizationRequestUrl non può essere risolto. Si indirettamente riferimento dal file necessari .class"

Qui è la mia codice:

String clientId = "YOUR_CLIENT_ID"; 
    String clientSecret = "YOUR_CLIENT_SECRET"; 

    // Or your redirect URL for web based applications. 
    String redirectUrl = "urn:ietf:wg:oauth:2.0:oob"; 
    String scope = "https://www.googleapis.com/auth/calendar"; 

    // Step 1: Authorize --> 
    String authorizationUrl = new GoogleAuthorizationRequestUrl(clientId, 
      redirectUrl, scope).build(); 

    // Point or redirect your user to the authorizationUrl. 
    System.out.println("Go to the following link in your browser:"); 
    System.out.println(authorizationUrl); 

    // Read the authorization code from the standard input stream. 
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); 
    System.out.println("What is the authorization code?"); 
    String code = in.readLine(); 
    // End of Step 1 <-- 

    // Step 2: Exchange --> 
    AccessTokenResponse response = new GoogleAuthorizationCodeGrant(
      httpTransport, jsonFactory, clientId, clientSecret, code, 
      redirectUrl).execute(); 
    // End of Step 2 <-- 

    GoogleAccessProtectedResource accessProtectedResource = new GoogleAccessProtectedResource(
      response.accessToken, httpTransport, jsonFactory, clientId, 
      clientSecret, response.refreshToken); 

    com.google.api.services.calendar.Calendar service = new com.google.api.services.calendar.Calendar.Builder(
      httpTransport, accessProtectedResource, jsonFactory).setApplicationName(
      "AppName").build(); 

Qualsiasi tipo di aiuto è apprezzato.

risposta

0

Questo errore può essere dovuto all'errata configurazione nella console API. Assicurati che il tuo progetto sia configurato come "Applicazione installata".

Questo thread può essere d'aiuto.

Problemi correlati