我无法通过服务帐户和目录API获取所有公司日历资源。当我使用我的用户帐户获取资源时,一切都很好。不知何故,服务帐户和我的用户帐户不共享公司日历资源。我从服务帐户得到的响应如下:
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'
}
]
}如何让我的服务帐户获取资源?
发布于 2021-10-18 14:32:08
您需要将委派设置为工作区域中的用户,以便委派为。
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')https://stackoverflow.com/questions/69615695
复制相似问题