我已经实现了一个c#app,它使用日历API创建日历事件。
为了使日历与我们的本地数据库保持同步,我在日历上创建了一个手表。以下代码执行此操作,并且据我所知,创建了一个监视。
Channel watchChannel = new Channel()
{
Id = ConfigurationManager.AppSettings["GOOGLE_CALENDAR_WATCH_NAME"],
Type = "web_hook",
Address = ConfigurationManager.AppSettings["GOOGLE_CALENDAR_SYNC_TRIGGER_CALLBACK_URL"],
Expiration = (unixTimestamp + NINETY_DAYS_IN_SECONDS) * 1000 //milliseconds
};
try
{
logger.Debug("Creating calendar watch with the name " +
ConfigurationManager.AppSettings["GOOGLE_CALENDAR_WATCH_NAME"] + " for calendar with id " + remoteCalendarId);
Channel returnChannel = service.Events.Watch(watchChannel, remoteCalendarId).Execute();
我的问题是没有调用回调URL(我已经确认了域的所有权并为用户进行了身份验证,这应该不是问题)。
04.04 - 更多信息:
这些是在拨出电话(watchChannel)和return-object(returnChannel)上设置的参数。
watchChannel
returnChannel
再看一遍,我还有一些问题:
验证代码
我使用以下代码对系统用户进行身份验证,然后以“正常”非系统帐户的形式进行操作(因为如果您真的想看一下纯粹的系统帐户似乎是一个棘手的方法日历也是如此。
ServiceAccountCredential credential =
GoogleCredential.FromJson(GOOGLE_SYSTEM_USER_AUTH_INFORMATION)
.CreateScoped(Scopes)
.UnderlyingCredential as ServiceAccountCredential;
var userField =
typeof(ServiceAccountCredential).GetField("user", BindingFlags.NonPublic | BindingFlags.Instance);
userField?.SetValue(credential, GOOGLE_CALENDAR_USERNAME); //Act in the guise of the normal user GOOGLE_CALENDAR_USERNAME
service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
一时兴起我访问了返回的ResourceURI。它给了我
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
是
答案 0 :(得分:0)
回调URL必须为https(证书),否则将不会被调用!