我正在尝试使用Google Apps电子邮件迁移API开发winform应用程序。我也想用两条腿的oAuth。
我已经成功地使用了具有联系人数据应用程序接口的两条腿的oAuth。为此,我在“管理客户端API访问”页面上设置了API作用域“http(S)://www.google.com/m8/feed/”。(http://www.google.com/support/a/bin/answer.py?hl=en&answer=162106)
对于电子邮件迁移Api,我将作用域设置为"https://apps-apis.google.com/a/feeds/migration"。但我收到"401: UnAuthorized access“错误。
我的代码是这样的:
GOAuthRequestFactory requestFactory = new GOAuthRequestFactory("MailItemService", "company-application-v1");
requestFactory.ConsumerKey = "domainname";
requestFactory.ConsumerSecret = "consumersecret";
MailItemService mailItemService = new MailItemService("domainname", "company-application-v1");
mailItemService.RequestFactory = requestFactory;
MailItemEntry entry = new MailItemEntry();
entry.Rfc822Msg = new Rfc822MsgElement(rfcTextOfMessage);
entry.MailItemProperties.Add(MailItemPropertyElement.STARRED);
entry.MailItemProperties.Add(MailItemPropertyElement.UNREAD);
entry.MailItemProperties.Add(MailItemPropertyElement.INBOX);
entry.Labels.Add(new LabelElement("Friends"));
entry.Labels.Add(new LabelElement("Event Invitations"));
entry.BatchData = new GDataBatchEntryData();
entry.BatchData.Id = "0";
MailItemEntry[] entries = new MailItemEntry[1];
entries[0] = entry;
MailItemFeed feed = mailItemService.Batch("domainname", user, entries);如何使用电子邮件迁移接口实现两条腿的oAuth。
谢谢!
发布于 2013-01-16 02:49:26
要在OAuth 1.0a中使用两条腿的OAuth,您需要指定由谁执行该操作。这是API将检查是否具有正确访问权限的用户。由于使用者密钥和密钥提供了对您的域的完全访问权限,因此您可以模拟任何用户,并让请求以他们的身份通过。
在使用电子邮件迁移API的情况下,您需要模拟要将电子邮件迁移到的用户。将URL参数"xoauth_requestor_id“设置为用户的完整电子邮件地址,请求就会通过。
发布于 2013-01-16 05:15:03
范围是:
https://apps-apis.google.com/a/feeds/migration/您的代码中缺少最后一个/。此外,如果您使用的是Google Apps域的主OAuth密钥(密钥是主域),但您正在迁移到辅助域用户,则需要手动授予主OAuth密钥对所有域的访问权限,或者设置第三方OAuth客户端。Google的Exchange迁移工具的管理员指南介绍了如何配置此工具:
http://static.googleusercontent.com/external_content/untrusted_dlcp/www.google.com/en/us/support/enterprise/static/gapps/docs/admin/en/gapps_exchange_migration/gamme_admin.pdf#page=19
https://stackoverflow.com/questions/6152878
复制相似问题