AnsweredAssumed Answered

Use Python-API behind Proxy

Question asked by mu88 on Jun 13, 2017
Latest reply on Feb 23, 2018 by rajk

I'm trying to use the new Python-API with our on-premise system. Our company runs it's own public key infrastructure, so I've configured Portal for ArcGIS with a corresponding certificate. Furthermore, there is a company-wide proxy that we are using.


As a first throw, I'd like to connect to ArcGIS Online by doing this:

from arcgis.gis import GIS
my_gis = GIS()

This crashes with:

c:\Program Files\ArcGIS\Pro\bin\Python>python.exe "C:\temp\"
Traceback (most recent call last):
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\", line 1254
, in do_open
h.request(req.get_method(), req.selector,, headers)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 1106, i
n request
self._send_request(method, url, body, headers)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 1151, i
n _send_request
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 1102, i
n endheaders
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 934, in
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 877, in
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 1252, i
n connect
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 853, in
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 832, in
OSError: Tunnel connection failed: 407 authenticationrequired

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\temp\", line 7, in <module>
my_gis = GIS()
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\site-packages\arcgis\",
line 95, in __init__
verify_cert=self._verify_cert, client_id=self._client_id)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\site-packages\arcgis\_impl\po", line 160, in __init__
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\site-packages\arcgis\_impl\co", line 281, in __init__
self.login(username, password, expiration, client_id)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\site-packages\arcgis\_impl\co", line 504, in login
resp ='', { 'f': 'json' }, add_token=False) # probe portal to fin
d auth scheme
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\site-packages\arcgis\_impl\co", line 1031, in post
resp =, data=encoded_postdata.encode())
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\", line 466,
in open
response = self._open(req, data)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\", line 484,
in _open
'_open', req)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\", line 444,
in _call_chain
result = func(*args)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\", line 1297
, in https_open
context=self._context, check_hostname=self._check_hostname)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\", line 1256
, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error Tunnel connection failed: 407 authenticati

Is it related to some proxy issues and if yes, where do I have to configure the proxy?