• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps 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:
[SIZE=2]
[LEFT]HttpTransport httpTransport = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NetHttpTransport();
JacksonFactory jsonFactory = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] JacksonFactory();

[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// The clientId and clientSecret are copied from the API Access tab on[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// the Google APIs Console[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]String clientId = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]clientID[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
String clientSecret = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]clientSecret[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];

[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Or your redirect URL for web based applications.[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]String redirectUrl = [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"urn:ietf:wg:oauth:2.0:oob"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
String scope = [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"https://www.googleapis.com/auth/calendar"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];

[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Step 1: Authorize -->[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]String authorizationUrl = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] GoogleAuthorizationRequestUrl(clientId, redirectUrl, scope)
.build();

 [/LEFT]
[SIZE=2]String code = some really long code[/SIZE][SIZE=2];[/SIZE][/SIZE]
[SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// End of Step 1 <--[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Step 2: Exchange -->[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]AccessTokenResponse response = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] GoogleAuthorizationCodeGrant(httpTransport, jsonFactory,
clientId, clientSecret, code, redirectUrl).execute();
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// End of Step 2 <--[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]
GoogleAccessProtectedResource accessProtectedResource = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] GoogleAccessProtectedResource(
response.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]accessToken[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], httpTransport, jsonFactory, clientId, clientSecret,
response.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]refreshToken[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]///*[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]Calendar [U]service[/U] = Calendar.[I]builder[/I](httpTransport, jsonFactory)
.setApplicationName([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"YOUR_APPLICATION_NAME"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
.setHttpRequestInitializer(accessProtectedResource)[/LEFT]
.build();
[/SIZE]
 
Back
Top Bottom