嗯,基本上我迷失了这个任务。我需要使用api google privedes获取群组的所有成员。我从gmail quickstart示例开始,首先我配置了Api项目和OAuth客户端。
我的第一个测试是查看收件箱中所有的邮件,一切正常。但是要对迷路的小组成员做同样的事情,我找不到解决办法。
有什么主意吗?
from __future__ import print_function
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
import json
import requests
SCOPES = 'https://www.googleapis.com/auth/admin.directory.group.member'
def main():
store = file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('gmail', 'v1', http=creds.authorize(Http()))
response = requests.get("https://www.googleapis.com/admin/directory/v1/groups/example@test.com/members")
print(response)
响应为:
<Response [401]>
答案 0 :(得分:0)
好像您从gmail示例开始,然后进行修改以访问admin / group功能
在https://developers.google.com/admin-sdk/directory/v1/quickstart/python
处查看管理文档。答案 1 :(得分:0)
这里是函数,它将检索所有组的电子邮件地址
def retrieving_groups():
response_group = service.groups().list(customer='my_customer').execute()
for group in response_group['groups']:
print(group['email'])