5

I am new to Google Project and i have to integrate Google Calendar and Google Task in my project. for this i am refferring [https://developers.google.com/google-apps/calendar/instantiate][1]. I have already added:

google play services as library google-api-services-calendar-v3-rev81-java-1.18.0-rc.

But it is showing error "The type com.google.api.client.auth.oauth2.draft10.AuthorizationRequestUrl cannot be resolved. It is indirectly referenced from required .class files"

Here is my code:

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

Any sort of help is appreciated.

Amrit Pal Singh
  • 7,116
  • 7
  • 40
  • 50
Aayushi
  • 574
  • 3
  • 14

1 Answers1

0

This error maybe due to the misconfiguration in the API console. Make sure your project is setup as "Installed Application."

This thread maybe of help.

Community
  • 1
  • 1
Devan
  • 35
  • 6