Google应用程序电子邮件迁移API支持两条腿的oAuth吗?
我正在尝试使用Google Apps电子邮件迁移API开发winform应用程序。我还想使用两条腿的oAuth 我已经成功地将两条腿的oAuth与contacts数据API一起使用。为此,我在“管理客户端API访问”页面上设置了API范围“http(s)://www.google.com/m8/feeds/”。(http://www.google.com/support/a/bin/answer.py?hl=en&answer=162106) 对于电子邮件迁移Api,我将范围设置为“https://apps-apis.google.com/a/feeds/migration". 但我得到了“401:未授权访问”错误 我的代码是这样的:Google应用程序电子邮件迁移API支持两条腿的oAuth吗?,oauth,google-apps,google-email-migration,Oauth,Google Apps,Google Email Migration,我正在尝试使用Google Apps电子邮件迁移API开发winform应用程序。我还想使用两条腿的oAuth 我已经成功地将两条腿的oAuth与contacts数据API一起使用。为此,我在“管理客户端API访问”页面上设置了API范围“http(s)://www.google.com/m8/feeds/”。(http://www.google.com/support/a/bin/answer.py?hl=en&answer=162106) 对于电子邮件迁移Api,我将范围设置为“https:
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);
如何使用电子邮件迁移API实现两条腿的oAuth
谢谢 要在OAuth 1.0a中使用双腿OAuth,需要指定执行操作的人。这是API将检查是否正确访问的用户。由于使用者密钥和机密授予您对域的完全访问权,因此您可以模拟任何用户,并让请求以他们的身份通过 对于电子邮件迁移API,您需要模拟您将电子邮件迁移到的用户。将URL参数“xoauth_requestor_id”设置为用户的完整电子邮件地址,请求应通过。范围为:
https://apps-apis.google.com/a/feeds/migration/
您的代码中缺少最后一个/。此外,如果您正在使用Google Apps域的主OAuth密钥(该密钥是主域),但要迁移到辅助域用户,则需要手动授予对所有域的主OAuth密钥访问权限,或者设置第三方OAuth客户端。《谷歌Exchange迁移工具管理指南》介绍了如何配置该工具: