httplib2.ServerNotFoundError: Невозможно найти сервер на сайте www.googleapis.com. - PullRequest
0 голосов
/ 15 мая 2019

Когда я пытаюсь получить сведения о gmail с помощью google-api (googleapiclient, oauth2client), я получаю сообщение об ошибке ниже:

Файл "", строка 1, в Файл "/usr/local/lib/python2.7/site-packages/google_api_python_client-1.7.8-py2.7.egg/googleapiclient/_helpers.py", строка 130, в positional_wrapper

Файл "/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", строка 2135, в запросе cachekey, Файл "/usr/local/lib/python2.7/site-packages/httplib2-0.12.1-py2.7.egg/httplib2/init.py", строка 1796, в _request conn, request_uri, метод, тело, заголовки Файл "/usr/local/lib/python2.7/site-packages/httplib2-0.12.1-py2.7.egg/httplib2/init.py", строка 1707, в _conn_request

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)

Любая помощь будет высоко ценится

Заранее спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...