授权客户端还是范围试图运行我的代码,当我得到这个错误: 谷歌API的Python unauthorized_client:在请求
oauth2client.client.AccessTokenRefreshError: unauthorized_client: Unauthorized client or scope in request.
这里是我的代码:
import json
import requests
import httplib2
from oauth2client.client import SignedJwtAssertionCredentials
from apiclient.discovery import build
if __name__ == '__main__':
json_key_file = 'my-key.json'
with open(json_key_file) as json_file:
json_data = json.load(json_file)
credential = SignedJwtAssertionCredentials(json_data['client_email'], json_data['client_email'], json_data['private_key'], scope=['https://www.googleapis.com/auth/admin.directory.user','https://www.googleapis.com/auth/admin.directory.user.readonly'], sub='[email protected]')
http = httplib2.Http()
http = credential.authorize(http)
service = build('admin', 'directory_v1', http=http)
data = service.users().list(domain='domain.com').execute()
print data
我有范围集正确地在我的控制台中,并且我的控制台中启用了我的Admin SDK。 我的电子邮件是一个可以访问所有Admin API权限的超级管理员。
为什么我会得到这个错误?
https://developers.google.com/admin-sdk/directory/v1/guides/代表团我认为你在创建服务帐户和凭证下忘记了第一步。 – DaImTo 2014-12-04 13:52:15