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.