1

I'm using Google calendar API v3 via the .NET client library to build an installed app. In my developer console I have a project defined with the Calendar API on. I am able to add events okay, but cannot clear the calendar. The following code works from the account that created the project, but won't work for any other account (returns 403 forbidden):

UserCredential credential;
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
    new ClientSecrets
    {
        ClientId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
        ClientSecret = "yyyyyyyyyyyyyyyyyyy"
    },
    new[] { CalendarService.Scope.Calendar },
    "johndoe@gmail.com",
    CancellationToken.None,
    new FileDataStore("Somefolder"));

// Create the service
cs = new CalendarService(new BaseClientService.Initializer()
{
    HttpClientInitializer = credential,
    ApplicationName = "Calendar App",
});

cs.Calendars.Clear("primary").Execute(); // 403 returned here

How can I correct this, so I am able to clear a user's primary calendar? I've seen other posts talking about making the user share their calendar, but this isn't practical, and they've given my app Calendar API permission already.

Community
  • 1
  • 1
Mark
  • 440
  • 4
  • 16
  • This solution worked for me: http://stackoverflow.com/questions/11863022/edit-google-calendar-events-from-google-service-account-403/11897793#11897793 –  Jan 22 '15 at 08:13

1 Answers1

1

The problem turned out not to be with the above code or my project setup. It was a problem specific to the one account I tested with. Even trying to "Delete all events in calendar" through the web interface resulted in this same error for this particular account. Tested it on several other accounts, and they work fine. From searching around it appears this is a not too uncommon problem people can run into. I incorrectly attributed it to the code, but it was some problem specific to that account.

Mark
  • 440
  • 4
  • 16