Is there a method to change a Google Calendar's access level?
I have the following code to create a new calendar for a gmail contact:
// Create a CalenderService and authenticate
CalendarService myService = new CalendarService("exampleCo-exampleApp-1");
myService.setUserCredentials("email@email.com", "password");
CalendarEntry calendar = 开发者_StackOverflownew CalendarEntry
{
Title = { Text = "Example title" },
Summary = { Text = "Example summary" },
TimeZone = "Europe/London",
Hidden = false,
Color = "#2952A3",
Location = new Where("", "", "Location"),
};
Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
CalendarEntry createdCalendar = (CalendarEntry)myService.Insert(postUri, calendar);
Is there some other method or property I can use to share this calendar, in the constructor or after it's been created? I've looked through everything but nothing's jumped out, been googling and looking around this site also but have had no luck.
I've seen examples of how to set each the access level of each event try indidually, but not the whole calendar which is possible by clicking through Google's calendar settings.
Thanks
Found a soution for anyone who comes across this:
string postUristring = string.Empty;
// note this could change in future!
string feedString = createdCalendar.Id.AbsoluteUri.LastIndexOf("/") + 1;
postUristring = feedString.Substring(0, feedString.Length - 28);
AclEntry entry = new AclEntry();
entry.Scope = new AclScope();
entry.Scope.Type = AclScope.SCOPE_DEFAULT;
entry.Role = new AclRole();
entry.Role = AclRole.ACL_CALENDAR_READ;
Uri aclUri = new Uri("http://www.google.com/calendar/feeds/"
+ postUristring + "@group.calendar.google.com" + "/acl/full");
AclEntry insertedEntry = myService.Insert(aclUri, entry);
精彩评论