首页 > 解决方案 > Google Apps 超级管理员对域用户日历的访问权限

问题描述

我有大量资源日历,我的用户需要根据他们的角色拥有不同程度的访问权限。我正在编写一个应用程序来管理这些 Acl 规则,但还想管理哪些日历出现在最终用户日历提要中(即我不想让他们突然看到所有 130 个资源日历并且必须过滤它们)

我需要使用 CalendarList api 访问,但是当我通过 users//calendarList 而不是 users/me/calendarList 授权超级管理员凭据时,服务返回 404 响应。

我的目标是遍历我的共享日历资源列表,并为每个读者或 freeBusyReader 用户设置他们的 calendarListEntry.hidden 为 true。

标签: google-calendar-api

解决方案


于是,我发现了答案。为了模拟用户,您必须在初始化服务帐户凭据时将“用户”设置为您希望模拟的电子邮件地址:

public static ServiceAccountCredential Credential(string[] Scopes, string impersonateEmail = null) { ServiceAccountCredential cred = ServiceAccountCredential.FromServiceAccountData(credential_stream); var initializer = new ServiceAccountCredential.Initializer(cred.Id) { User = string.IsNullOrEmpty(impersonateEmail)?service_acct:impersonateEmail, Key = cred.Key, Scopes = Scopes }; return new ServiceAccountCredential(initializer); }


推荐阅读