2017-02-21 6 views
0

Я использую ниже пример кода для подключения google pubsub из скрипта python. Моя организация использует прокси для подключения к Интернету. не могли бы вы рассказать мне, как настроить прокси-настройки в облаке Google? Я пробовал устанавливать переменную env_version, но все равно не удается.Настройки прокси в google pubsub

import json 
from oauth2client.contrib.gce import AppAssertionCredentials 
from oauth2client.service_account import ServiceAccountCredentials 
from httplib2 import Http 
from apiclient.discovery import build 

credentials =   AppAssertionCredentials('https://www.googleapis.com/auth/pubsub') 
scopes = ['https://www.googleapis.com/auth/pubsub', ' https://www.googleapis.com/auth/cloud-platform','https://www.googleapis.com/auth/monitoring', 'https://www.googleapis.com/auth/monitoring.write' ,'https://www.googleapis.com/auth/cloud-platform' , 'https://www.googleapis.com/auth/monitoring.read'] 
credentials = ServiceAccountCredentials.from_json_keyfile_name('path to json file', scopes=scopes) 
http_auth = credentials.authorize(Http()) 
pubsub1 = build('pubsub', 'v1',http=http_auth) 

ответ

0

Он работал с помощью команды ниже:

http_auth = credentials.authorize(Http(proxy_info =  httplib2.ProxyInfo(httplib2.socks.PROXY_TYPE_HTTP_NO_TUNNEL, 'proxy url wihout  http://', 8080, proxy_user = '', proxy_pass = ''))) 

вместо http_auth = credentials.authorize (HTTP())

Смежные вопросы