首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Google服务帐户列出所有现有日历资源(目录API)

使用Google服务帐户列出所有现有日历资源(目录API)
EN

Stack Overflow用户
提问于 2021-10-18 12:00:30
回答 1查看 71关注 0票数 0

我无法通过服务帐户和目录API获取所有公司日历资源。当我使用我的用户帐户获取资源时,一切都很好。不知何故,服务帐户和我的用户帐户不共享公司日历资源。我从服务帐户得到的响应如下:

代码语言:javascript
复制
config: {
url: 'https://www.googleapis.com/admin/directory/v1/customer/my_customer/resources/calendars',
method: 'GET',
paramsSerializer: [Function (anonymous)],
headers: {
  'Accept-Encoding': 'gzip',
  'User-Agent': 'google-api-nodejs-client/0.7.2 (gzip)',
  Authorization: 'Bearer <access_token>',
  Accept: 'application/json'
},
params: [Object: null prototype] {},
validateStatus: [Function (anonymous)],
responseType: 'json'
 },
  code: 404,
  errors: [
    {
      message: 'Resource Not Found',
      domain: 'global',
      reason: 'notFound'
    }
  ]
}

如何让我的服务帐户获取资源?

EN

回答 1

Stack Overflow用户

发布于 2021-10-18 14:32:08

您需要将委派设置为工作区域中的用户,以便委派为。

代码语言:javascript
复制
from google.oauth2 import service_account

SCOPES = ['https://www.googleapis.com/auth/admin.directory.user']
SERVICE_ACCOUNT_FILE = '/path/to/service.json'

credentials = service_account.Credentials.from_service_account_file(
        SERVICE_ACCOUNT_FILE, scopes=SCOPES)

delegated_credentials = credentials.with_subject('user@yourdomain.com')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69615695

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档