嗨我正在编写一个使用GAE Java的连接器工具,它添加,更新,删除和检索日历events.I使用2腿认证相同。我能够使用双方认证成功添加新事件,但无法使用相同的更新,删除或检索事件。使用GAE Java API无法更新/删除/检索日历事件使用双腿认证使用GAE Java API
当我尝试对日历事件进行更新/删除/检索操作时,它会给出以下错误。
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>
相同的代码工作正常,如果我删除OAuth的特定代码,只需使用service.setUserCredentials()方法。
请帮我解决这个问题。请在 的情况下恢复原状,需要更多相关信息。
在此先感谢。
-Nirzari 下面是代码片段
//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();
非常感谢您的回复,添加了query.addCustomParameter(新的CustomParameter(“xoauth_requestor_id”,userEmail));只是为我工作。 – user1024966
我很乐意提供帮助。可惜你不能投票作为新手:) – lukelazarovic