目标:我的python网络应用访问客户的Google用户信息。他们已经使用该服务帐户JSON文件作为对我的应用程序的凭据,向服务帐户提供了访问admin.directory.user.readonly和Im范围的授权。credential_path = os.path.join(os.path.dirname(app.instance_path),'cre.json')os.environ ['GOOGLE_APPLICATION_CREDENTIALS'] = credential_path
SCOPES = ['https://www.googleapis.com/auth/admin.directory.user.readonly']
PATH_TO_CREDENTIALS = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS')
GET_CREDENTIALS = PATH_TO_CREDENTIALS
PASS_CREDENTIALS = service_account.Credentials.from_service_account_file(GET_CREDENTIALS, scopes=SCOPES)
service = build('admin', 'directory_v1', credentials=PASS_CREDENTIALS)
# Call the Admin SDK Directory API
print('Getting the first 10 users in the domain')
results = service.users().list(customer='customer.com', domain='customer.com', maxResults=10, orderBy='email').execute()
users = results.get('users', [])
for user in users:
print(u'{0} ({1})'.format(user['primaryEmail'], user['name']['fullName']))
我越来越:
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://admin.googleapis.com/admin/directory/v1/users?customer=nidec-ga.com&domain=nidec-ga.com&maxResults=10&orderBy=email&alt=json returned "Bad Request". Details: "Bad Request">
知道有什么问题吗?
您不能在同一GET请求上使用domain
和customer
。在Admin Google API文档中,该domain
字段的内容如下:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句