具有 2 条腿 OAuth 的 Google Apps 电子邮件审核 API

发布于 2024-12-23 06:37:32 字数 2541 浏览 1 评论 0 原文

我目前正在尝试使用 GData .net API

以下是我正在使用的文档 http://code.google.com/googleapps/domain/audit/docs/1.0/audit_developers_guide_protocol.html#retriving_all_mailbox_status

我想做的是使用 2 条腿身份验证来执行此操作 这个例子

using System;
using Google.GData.Apps;
using Google.GData.Extensions.Apps;
...

MailMonitor monitor = new MailMonitor();
monitor.BeginDate = new DateTime(2009, 6, 15);
monitor.EndDate = new DateTime(2009, 6, 30, 23, 20, 0);
monitor.IncomingEmailMonitorLevel = MonitorLevel.FULL_MESSAGE;
monitor.OutgoingEmailMonitorLevel = MonitorLevel.HEADER_ONLY;
monitor.DraftMonitorLevel = MonitorLevel.FULL_MESSAGE;
monitor.ChatMonitorLevel = MonitorLevel.FULL_MESSAGE;
monitor.DestinationUserName = "namrata";

AuditService service = new AuditService("example.com", "example.com-auditapp-v1");
service.setUserCredentials("[email protected]", "p@55w0rd");
MailMonitor monitorEntry = service.CreateMailMonitor("abhishek", monitor);

我得到的

var monitor = new MailMonitor
            {
                EndDate = DateTime.Now.AddDays(1),
                IncomingEmailMonitorLevel = MonitorLevel.FULL_MESSAGE,
                OutgoingEmailMonitorLevel = MonitorLevel.HEADER_ONLY,
                DraftMonitorLevel = MonitorLevel.FULL_MESSAGE,
                ChatMonitorLevel = MonitorLevel.FULL_MESSAGE,
                DestinationUserName = "MYUSER"
            };
            var service = new AuditService("MYDOMAIN", "MYDOMAIN-auditapp-v1");
            var requestFactory = new GOAuthRequestFactory("auditapi", "MYDOMAIN-auditapp-v1")
                                     {
                                         ConsumerKey = "MYDOMAIN", 
                                        ConsumerSecret = "MYKEY"
                                     };
            service.RequestFactory = requestFactory;
            var monitorEntry = service.CreateMailMonitor("MYUSER", monitor);

是尝试为一天内发送或发送的任何电子邮件设置一个监视器。响应是未知授权标头(错误 401)。

我通过遵循本指南 http:// /code.google.com/googleapps/domain/articles/2lo-in-tasks-for-admins.html

我不知道如何调试这个,我找不到 2 条腿身份验证的示例电子邮件审核 API 和我无法使用wireshark,因为这是加密的流量。

I'm currently trying to use the GData .net API

Here is the documentation I'm using http://code.google.com/googleapps/domain/audit/docs/1.0/audit_developers_guide_protocol.html#retrieving_all_mailbox_status

What I'm trying to do is to use 2 legged authentication to do this example

using System;
using Google.GData.Apps;
using Google.GData.Extensions.Apps;
...

MailMonitor monitor = new MailMonitor();
monitor.BeginDate = new DateTime(2009, 6, 15);
monitor.EndDate = new DateTime(2009, 6, 30, 23, 20, 0);
monitor.IncomingEmailMonitorLevel = MonitorLevel.FULL_MESSAGE;
monitor.OutgoingEmailMonitorLevel = MonitorLevel.HEADER_ONLY;
monitor.DraftMonitorLevel = MonitorLevel.FULL_MESSAGE;
monitor.ChatMonitorLevel = MonitorLevel.FULL_MESSAGE;
monitor.DestinationUserName = "namrata";

AuditService service = new AuditService("example.com", "example.com-auditapp-v1");
service.setUserCredentials("[email protected]", "p@55w0rd");
MailMonitor monitorEntry = service.CreateMailMonitor("abhishek", monitor);

I've gotten as far as

var monitor = new MailMonitor
            {
                EndDate = DateTime.Now.AddDays(1),
                IncomingEmailMonitorLevel = MonitorLevel.FULL_MESSAGE,
                OutgoingEmailMonitorLevel = MonitorLevel.HEADER_ONLY,
                DraftMonitorLevel = MonitorLevel.FULL_MESSAGE,
                ChatMonitorLevel = MonitorLevel.FULL_MESSAGE,
                DestinationUserName = "MYUSER"
            };
            var service = new AuditService("MYDOMAIN", "MYDOMAIN-auditapp-v1");
            var requestFactory = new GOAuthRequestFactory("auditapi", "MYDOMAIN-auditapp-v1")
                                     {
                                         ConsumerKey = "MYDOMAIN", 
                                        ConsumerSecret = "MYKEY"
                                     };
            service.RequestFactory = requestFactory;
            var monitorEntry = service.CreateMailMonitor("MYUSER", monitor);

This is trying to setup a monitor for any emails coming or going for one day. The response is Unknown authorization header (Error 401).

I got the key from following this guide http://code.google.com/googleapps/domain/articles/2lo-in-tasks-for-admins.html

I've no idea how to debug this, I can't find an example of 2 legged auth with the Email Audit API and I can't use wireshark because this is encrypted traffic.

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

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

发布评论

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

评论(1

只是偏爱你 2024-12-30 06:37:32

你用的是什么键?
请记住 API 密钥与消费者秘密不同。消费者秘密是您所在域所独有的。

您可以通过转到您域的 Cpanel -> 来找到您的消费者秘密。高级设置->管理 OAuth 域密钥。这是您的域和 Google 共享的秘密。
此处是一份供您参考的文档。

What key did you use?
Remember API key is not the same as Consumer Secret. Consumer Secret is something which is unique to your domain.

You can find your consumer secret by going to your domain's Cpanel -> Advanced Settings -> Manage OAuth Domain Key. This is the secret your domain and Google share.
Here is a doc for your reference.

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