Hello,

Hi I am writing a  connector tool which adds,updates, deletes and
retrieves calendar events.
I am using 2 legged authentication for the same. I am able to add new
events successfully using 2 legged authentication but not able to
update, delete or retrieve events using the same.
It gives following error while I try to do either of update/delete/
retrieve operation on calendar event.

com.google.gdata.util.AuthenticationException: OK
<HTML>
<HEAD>
<TITLE>Token invalid - Invalid AuthSub token.</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Token invalid - Invalid AuthSub token.</H1>
<H2>Error 401</H2>
</BODY>
</HTML>

Following are the code snippets of getCalendarEvents and
updateCalendarEvent.
//Code for getCalendarEvents
String url = FEED_URL + "?xoauth_requestor_id="
                                        + "[email protected]";
URL postUrl = new URL(url);
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
                oauthParameters.setScope(Scope);
                oauthParameters.setOAuthConsumerKey(ConsumerKey);
                oauthParameters.setOAuthConsumerSecret(secret);

CalendarService myService = new CalendarService("getAppointments");
OAuthSigner signer = new OAuthHmacSha1Signer();
myService.setOAuthCredentials(oauthParameters, signer);
CalendarQuery myQuery = new CalendarQuery(postUrl);
CustomParameter customParameter = new CustomParameter("showdeleted",
"true");
myQuery.addCustomParameter(customParameter);
CalendarEventFeed resultFeed = myService.query(myQuery,
                                        CalendarEventFeed.class);

//Code for Update Appointment
String url = FEED_URL + "?xoauth_requestor_id="                                 
+
"[email protected]";

URL postUrl = new URL(url);
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setScope(Scope);
oauthParameters.setOAuthConsumerKey(ConsumerKey);
oauthParameters.setOAuthConsumerSecret(secret);
CalendarService myService = new CalendarService("updateAppointment");
OAuthSigner signer = new OAuthHmacSha1Signer();
myService.setOAuthCredentials(oauthParameters, signer);
CalendarQuery myQuery = new CalendarQuery(postUrl);
myQuery.setExtendedPropertyQuery(new ExtendedPropertyMatch(
                                        "Prop_Name", value));
CalendarEventFeed resultFeed = myService.getFeed(myQuery,
                                        CalendarEventFeed.class);

if (resultFeed != null && resultFeed.getEntries().size() > 0) {
CalendarEventEntry matchEntry = (CalendarEventEntry) resultFeed
                                                .getEntries().get(0);
updateCalendarEntry(matchEntry, description, title, start, end,
                                                startTime, endTime, location, 
priavte, guestList);
matchEntry.update();

The same code works fine if I remove OAuth specific code and just use
service.setUserCredentials() method.

Kindly help me out to resolve this issue. Please revert back in case
more information on this is required.

Thanks in advance.

-Nirzari

-- 
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/calendar/community/forum.html

Reply via email to