当我尝试使用google-api的(googleapiclient,oauth2client)获取gmail的详细信息时,出现以下错误:
文件“”,第1行,在 在positional_wrapper中将文件“ /usr/local/lib/python2.7/site-packages/google_api_python_client-1.7.8-py2.7.egg/googleapiclient/_helpers.py”第130行
文件224中的文件“ /usr/local/lib/python2.7/site-packages/google_api_python_client-1.7.8-py2.7.egg/googleapiclient/discovery.py”,第224行
文件“ /usr/local/lib/python2.7/site-packages/google_api_python_client-1.7.8-py2.7.egg/googleapiclient/discovery.py”,行274,位于_retrieve_discovery_doc中 请求中的文件“ /usr/local/lib/python2.7/site-packages/httplib2-0.12.1-py2.7.egg/httplib2/init.py”,在请求中 快取键, _request中的文件1796行中的文件“ /usr/local/lib/python2.7/site-packages/httplib2-0.12.1-py2.7.egg/httplib2/init.py” conn,request_uri,方法,主体,标头 _conn_request中的文件1707行中的文件“ /usr/local/lib/python2.7/site-packages/httplib2-0.12.1-py2.7.egg/httplib2/init.py”>
raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
httplib2.ServerNotFoundError:无法在www.googleapis.com上找到服务器
但是它在我的电脑上可以正常工作,但不能从远程位置正常工作。
代码:
from googleapiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
credentials = ServiceAccountCredentials.from_json_keyfile_name(
"quickstart-1551349397232-e8bcb3368ae1.json", scopes=['https://www.googleapis.com/auth/admin.directory.group',
'https://www.googleapis.com/auth/admin.directory.user',
'https://www.googleapis.com/auth/admin.directory.domain',
'https://www.googleapis.com/auth/gmail.readonly'])
delegated_credentials = credentials.create_delegated('jango@carbonitedepot.com')
DIRECOTORY = build('admin', 'directory_v1', credentials=delegated_credentials)
try:
results = DIRECOTORY.users().list(customer='my_customer').execute()
users = results.get('users', [])
res = []
for info in users:
print(info)
res.append(info.get("primaryEmail"))
print(res)
except Exception as e:
print(e)
任何帮助将不胜感激
预先感谢
答案 0 :(得分:1)
我遇到了同样的问题,我进行了很多搜索以解决问题,结果发现我在这里有错。
I don't know from where there was podman installed instead of docker and that caused the problem.
我建议您检查docker版本,并确保最新版本正在服务器上运行,否则,库可以正常工作!如果您仍然遇到此问题,请告诉我!