【问题标题】:Does Google Apps Email Migration API support 2 legged oAuth?Google Apps 电子邮件迁移 API 是否支持 2 legged oAuth?
【发布时间】:2011-05-27 13:26:06
【问题描述】:

我正在尝试使用 Google Apps 电子邮件迁移 API 开发 winform 应用程序。我也想使用 2 legged oAuth。

我已成功使用 2 腿 oAuth 和联系人数据 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:未经授权的访问”错误。

我的代码是这样的:

            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 实现 2 腿 oAuth。

谢谢!

【问题讨论】:

    标签: oauth google-apps google-email-migration


    【解决方案1】:

    要在 OAuth 1.0a 中使用两腿式 OAuth,您需要指定执行操作的人员。这是 API 将检查访问权限的用户。由于使用者密钥和机密可以完全访问您的域,因此您可以模拟任何用户并让请求以他们的身份通过。

    对于电子邮件迁移 API,您需要模拟要将电子邮件迁移到的用户。将 URL 参数“xoauth_requestor_id”设置为用户的完整电子邮件地址,请求应该通过。

    【讨论】:

      【解决方案2】:

      范围是:

      https://apps-apis.google.com/a/feeds/migration/
      

      您缺少代码中的最后一个 /。此外,如果您正在使用 Google Apps 域的主 OAuth 密钥(该密钥是主域)但您要迁移到辅助域用户,则需要手动授予主 OAuth 密钥访问所有域或设置第 3 方 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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-07-30
        • 1970-01-01
        • 1970-01-01
        • 2011-01-21
        • 1970-01-01
        相关资源
        最近更新 更多