从 Google Apps 帐户访问 GData Calender?
我也在构建一个简单的应用程序,需要访问我的 Google Apps 帐户中的日历。但我在身份验证方面遇到问题。我已尝试以下代码,但它不起作用:
Service service = new Service("<appname>");
service.setUserCredentials("<email>", "<password>");
CalendarEntry entry = (CalendarEntry)service.Get("<eventUrl>");
How do you get this to work with Google Apps?对于 Google 应用程序,我还必须使用任何其他类型的身份验证吗?
更新:
解锁验证码解决了我获取提要的问题。现在我遇到了下一个难题:更新事件。
entry.Title.Text = "Foo";
entry.Update();
给我 GDataRequestException 异常:“无法更新只读条目”。
我使用我在 kalendarsettings 下获得的私人日历 xml 地址: https://www.google.com/calendar/feeds/_%40group.calendar。 google.com/private-/basic
I'm building a simple app too that needs to access a calendar that's in my Google Apps account. But I'm having problems with authentication. I've tried the following code but it doesn't work:
Service service = new Service("<appname>");
service.setUserCredentials("<email>", "<password>");
CalendarEntry entry = (CalendarEntry)service.Get("<eventUrl>");
How do you get this to work with Google Apps? Is there any other type of authentication that I have to use for Google apps?
Update:
Unlocking the captcha solved my problem with getting the feed. Now I've hit the next wall: updating an event.
entry.Title.Text = "Foo";
entry.Update();
Gives me the GDataRequestException exception: "Can not update a read-only entry".
Im using the private calendar xml address that I got under kalendarsettings:
https://www.google.com/calendar/feeds/_%40group.calendar.google.com/private-/basic
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议使用 Fiddler 来查看您从 Google 返回的 http 响应。当我针对我的谷歌应用程序帐户运行您的代码时,我收到了“Error=CaptchaRequired”响应。这要求我转至 https://www.google.com/a/yourgoogleappdomain.com /UnlockCaptcha(显然替换为您的域名)。完成此操作后,我能够正确连接。您也可能会收到不同的错误代码,因此请检查该错误代码并将其发布在此处。您的密码或网址可能无效,或者您的 Google Apps 管理员禁用了此功能。这是我的示例代码:
确保替换 URL 中的电子邮件、密码和电子邮件(URL 也对 @ 符号进行编码)。
I would recommend using Fiddler to see what http response you are getting back from Google. When I ran your code against my google apps account, I was getting back an "Error=CaptchaRequired" response. This required that I go to https://www.google.com/a/yourgoogleappdomain.com/UnlockCaptcha (replacing with your domain obviously). After I did that I was able to properly connect. You may be getting a different error code too so check for that and post it here. You could have an invalid password or invalid url or this functionality is disabled by your google apps administrator. Here is my sample code:
Make sure to replace the email, password, and email inside of the URL (url encode the @ sign too).
谷歌的奥斯汀提供了另一个解决方案(它对我有用):
http://groups.google.com /group/google-calendar-help-dataapi/browse_thread/thread/400104713435a4b4?pli=1
Yet another solution Austin from google provides (it worked for me):
http://groups.google.com/group/google-calendar-help-dataapi/browse_thread/thread/400104713435a4b4?pli=1