具有 2 条腿 OAuth 的 Google Apps 电子邮件审核 API
我目前正在尝试使用 GData .net API
我想做的是使用 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,因为这是加密的流量。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你用的是什么键?
请记住 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.