Unfortunately, Google has not updated the Java configuration source code at this time. You do not need these classes, and as others noted in their comments, they are deprecated.
Replace the import of "draft10" with:
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse; import com.google.api.services.calendar.CalendarScopes;
Then replace the authorization code (from the comment "Step 1: Authorization β" and further):
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( httpTransport, jsonFactory, clientId, clientSecret, Arrays.asList(CalendarScopes.CALENDAR)).setAccessType("online") .setApprovalPrompt("auto").build(); String url = flow.newAuthorizationUrl().setRedirectUri(redirectUrl).build(); System.out.println("Please open the following URL in your browser then type the authorization code:"); System.out.println(" " + url); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String code = br.readLine(); GoogleTokenResponse response = flow.newTokenRequest(code) .setRedirectUri(redirectUrl).execute(); GoogleCredential credential = new GoogleCredential() .setFromTokenResponse(response);
I had the same problem and I found the sample disk code for the update. I figured out my path and made it work. The "flow of authorization code" is described here .
source share