【发布时间】:2015-11-22 06:40:55
【问题描述】:
我在使用 Google 的目录 API 从电子邮件组中提取用户列表时遇到问题。这是我的代码:
CLIENT_SECRET = 'group_auth.p12'
CLIENT_EMAIL = "USER@developer.gserviceaccount.com"
with open(CLIENT_SECRET, "rb") as f:
PRIVATE_KEY = f.read()
f.close()
credentials = SignedJwtAssertionCredentials(CLIENT_EMAIL, PRIVATE_KEY, scope="https://www.googleapis.com/auth/admin.directory.group.readonly")
http = httplib2.Http()
http = credentials.authorize(http)
service = build("admin", "directory_v1", http)
request = service.members().get(groupKey=*taken-out*, memberKey="")
response = request.execute()
这是我收到的错误:
No handlers could be found for logger "oauth2client.util"
Traceback (most recent call last):
File "google_group_membership.py", line 21, in <module>
response = request.execute()
File "/Users/jleung/googleapi/lib/python2.7/site-packages/oauth2client/util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Users/jleung/googleapi/lib/python2.7/site-packages/googleapiclient/http.py", line 729, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/admin/directory/v1/groups/itgroup%40appdynamics.com/members/?alt=json returned "Not Authorized to access this resource/api">
在我的 google 控制台中,我确保我的 Google API 服务帐户具有正确的权限。任何帮助将不胜感激
谢谢
【问题讨论】:
标签: python api google-api google-api-python-client