AnsweredAssumed Answered

Use Python-API behind Proxy

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

Hi,
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\Test.py"
Traceback (most recent call last):
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\request.py", line 1254
, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\client.py", line 1106, i
n request
self._send_request(method, url, body, headers)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\client.py", line 1151, i
n _send_request
self.endheaders(body)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\client.py", line 1102, i
n endheaders
self._send_output(message_body)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\client.py", line 934, in
_send_output
self.send(msg)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\client.py", line 877, in
send
self.connect()
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\client.py", line 1252, i
n connect
super().connect()
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\client.py", line 853, in
connect
self._tunnel()
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\client.py", line 832, in
_tunnel
message.strip()))
OSError: Tunnel connection failed: 407 authenticationrequired

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\temp\Test.py", line 7, in <module>
my_gis = GIS()
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\site-packages\arcgis\gis.py",
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
rtalpy.py", line 160, in __init__
client_id=client_id)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\site-packages\arcgis\_impl\co
nnection.py", 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
nnection.py", line 504, in login
resp = self.post('', { '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
nnection.py", line 1031, in post
resp = opener.open(url, data=encoded_postdata.encode())
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\request.py", line 466,
in open
response = self._open(req, data)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\request.py", line 484,
in _open
'_open', req)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\request.py", line 444,
in _call_chain
result = func(*args)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\request.py", line 1297
, in https_open
context=self._context, check_hostname=self._check_hostname)
File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\request.py", line 1256
, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error Tunnel connection failed: 407 authenticati
onrequired>

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

Outcomes