Hi Alain, Thanks a lot for your reply.
Adding xoauth_requestor_id as a custom property in my code solved my problem i.e. rather then appending xoauth_requestor_id in my url I used following code: myQuery.addCustomParameter(new CustomParameter("xoauth_requestor_id", AUTH_REQUESTOR_ID)); Regards, Nirzari On Nov 3, 10:40 pm, Alain Vongsouvanh <ala...@google.com> wrote: > Hello, > > Though I don't think this is the cause of your issue, why are you > authorizing your service twice? You only need do it once when you set it up. > > Also, when updating event, please do as specified in the developer's > guide<http://code.google.com/apis/calendar/data/2.0/developers_guide_java.h...> > : > > URL editUrl = new URL(retrievedEntry.getEditLink().getHref()); > CalendarEventEntry updatedEntry = > (CalendarEventEntry)myService.update(editUrl, myEntry); > > Now, to have this work with 2-Legged OAuth, this is what you actually need > to do: > > URL editUrl = new URL(retrievedEntry.getEditLink().getHref() + > "?xoauth_requestor_id=usern...@domain.com"); > CalendarEventEntry updatedEntry = > (CalendarEventEntry)myService.update(editUrl, myEntry); > > Of course, you need to make sure that the editUrl is valid (if there was > another query parameter, use "&" instead of "?"). > > Best, > Alain > > On Wed, Nov 2, 2011 at 1:36 AM, Nirzari Bhatt > <nirzari.bh...@accenture.com>wrote: > > > > > > > > > > > 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=" > > + "u...@domain.com"; > > 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=" > > + > > "usern...@domain.com"; > > > 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 > > google-calendar-help-dataapi@googlegroups.com > > To unsubscribe from this group, send email to > > google-calendar-help-dataapi+unsubscr...@googlegroups.com > > For more options, visit this group at > >http://code.google.com/apis/calendar/community/forum.html > > -- > Alain Vongsouvanh | Developer Programs Engineer -- 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 google-calendar-help-dataapi@googlegroups.com To unsubscribe from this group, send email to google-calendar-help-dataapi+unsubscr...@googlegroups.com For more options, visit this group at http://code.google.com/apis/calendar/community/forum.html