December 9th, 2011, 09:46 AM
|
#1 (permalink)
|
|
Junior Member
Join Date: Sep 2011
Posts: 72
Device(s):
Thanks: 2
Thanked 1 Time in 1 Post
|
Google Calendar API HELP!
I'm trying to write an app that will allow me to read and write a users google calender. I've read the google tutorial on how to use the api but I'm having a really hard time. Below is my code, pretty much a copy and paste of googles. Once I reach the end of step 2 the remaing code is not execute. I've confirmed this with the eclipse debugger by setting breakpoints at that location and it doesn't break, the application just continues and pretty much skips the rest of the method. I'm sure I'm just doing something stupid, pleaes give me some guidance.
Thanks
Code:
HttpTransport httpTransport = new NetHttpTransport();
JacksonFactory jsonFactory = new JacksonFactory();
// The clientId and clientSecret are copied from the API Access tab on
// the Google APIs Console
String clientId = this.clientID;
String clientSecret = this.clientSecret;
// 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();
String code = some really long code;
// 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);
///*
Calendar service = Calendar.builder(httpTransport, jsonFactory)
.setApplicationName( "YOUR_APPLICATION_NAME")
.setHttpRequestInitializer(accessProtectedResource)
.build();
|
|
|