Google Apps 电子邮件迁移 API 是否支持 2 条腿 oAuth?

发布于 2024-11-09 19:20:32 字数 1601 浏览 3 评论 0原文

我正在尝试使用 Google Apps 电子邮件迁移 API 开发 winform 应用程序。我还想使用 2 条腿的 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/迁移”。但我收到“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。

谢谢!

I am trying to develop winform application using Google Apps Email migration API. I also want to use 2 legged oAuth.

I have successfully used 2 legged oAuth with contacts data API. To do this i have set the API scope "http(s)://www.google.com/m8/feeds/" on "Manage client API access" page. (http://www.google.com/support/a/bin/answer.py?hl=en&answer=162106)

For Email Migration Api I set the scope as "https://apps-apis.google.com/a/feeds/migration". But I am getting "401: UnAuthorized access" error.

My code is something like this:

            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);

How can we implement 2 legged oAuth with email migration API.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

于我来说 2024-11-16 19:20:33

要在 OAuth 1.0a 中使用两条腿 OAuth,您需要指定谁在执行操作。 API 将检查该用户是否具有正确的访问权限。由于消费者密钥和秘密可以完全访问您的域,因此您可以模拟任何用户并让请求以他们的身份通过。

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

To use two-legged OAuth in OAuth 1.0a, you need to specify who is performing the action. This is the user the API will check for proper access. Since the consumer key and secret give full access to your domain, you can impersonate any user and have the request go through as them.

In the case of the Email Migration API, you need to impersonate the user you're migrating emails to. Set the URL parameter "xoauth_requestor_id" to the full email address of the user and the requests should go through.

痕至 2024-11-16 19:20:33

范围是:

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#页=19

The scope is:

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

your missing the last / in your code. Also, if you're using the Google Apps domain's primary OAuth key (the key is the primary domain) but you're migrating to a secondary domain user, you'll need to either manually grant the primary OAuth key access to all domains or setup a 3rd party OAuth client. The Admin guide for Google's Exchange migration tool covers how this is configured:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文