我在尝试使用Google Calendar API删除事件时得到了一个GoogleApiExeption。设置:
public GoogleCalendarManager() //Setup tokens and stuff
{
using (var stream =
new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{
// The file token.json stores the user's access and refresh tokens, and is created
// automatically when the authorization flow completes for the first time.
string credPath = "token.json";
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}
// Create Google Calendar API service.
service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
}
删除功能:
public void deleteGoogleTask(Event newEvent)
{
service.Events.Delete("primary", newEvent.Id).Execute();
}
最后一行抛出异常。设置部分可用于接收日历事件。 newEvent id与Google文档中的“ Try this Api”一起使用,因此我认为设置部分存在问题。 感谢您的帮助。