2014-05-08 30 views
5

Tôi mới tham gia Dự án Google và tôi phải tích hợp Lịch Google và Google Task trong dự án của mình. cho điều này tôi đang refferring [https://developers.google.com/google-apps/calendar/instantiate][1]. Tôi đã thêm:Ủy quyền API Lịch Google Lỗi

dịch vụ google play làm thư viện google-api-services-calendar-v3-rev81-java-1.18.0-rc.

Nhưng nó đang hiển thị lỗi "Loại com.google.api.client.auth.oauth2.draft10.AuthorizationRequestUrl không thể được giải quyết. Nó được gián tiếp tham chiếu từ các tập tin cần thiết .class"

Đây là của tôi mã:

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(); 

Mọi loại trợ giúp đều được đánh giá cao.

Trả lời

0

Lỗi này có thể do cấu hình sai trong bảng điều khiển API. Đảm bảo dự án của bạn được thiết lập là "Ứng dụng đã cài đặt".

Điều này thread có thể trợ giúp.

Các vấn đề liên quan