Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

HTTP Error 407 #126

Closed
simoxu001 opened this issue Nov 20, 2015 · 7 comments
Closed

HTTP Error 407 #126

simoxu001 opened this issue Nov 20, 2015 · 7 comments

Comments

@simoxu001
Copy link

When I run the example code listLayersInHostedFeatureService.py, I get this error:

HTTPError: HTTP Error 407: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter

I have tried a few other example code, I got the same error .

the following code seems OK though, it doesn't cause any error when I step through it in debugging.

sh = arcrest.AGOLTokenSecurityHandler(myusername, mypassword, 'https://myorg.maps.arcgis.com/',None,'127.0.0.1',3128)

More details of my environment:
I am running the code behind a corporate proxy which is using NTLM authentication and causing trouble to work with some could services. so I am using Cntlm as a local proxy to mitigate the problem and it's been working for me to access AGOL.

@achapkowski
Copy link
Collaborator

What type of Proxy do you have?

@simoxu001
Copy link
Author

I am working behind a corporate firewall, we have a corporate proxy to access Internet. I found I could not assess AGOL using REST API in Python, so that I installed a local proxy on my computer called "Cntlm" which is serving on port 3128.

Code like the following will work if NOT using ArcREST:

    proxy_handler = urllib2.ProxyHandler({"http": "http://127.0.0.1:3128"})
    opener = urllib2.build_opener(proxy_handler)

    referer = "http://www.arcgis.com/"
    query_dict = {'username': username,
                  'password': password,
                  'referer': referer}

    query_string = urllib.urlencode(query_dict)
    token = json.loads(opener.open(url + "?f=json", query_string).read())

@achapkowski
Copy link
Collaborator

@lucksimo - the issue with proxy support is that there are many different types of proxies. ArcREST supports simple proxies.

You can try creating a local proxy on your machine that then handles the NTLM proxy needs.

Just an idea.

@simoxu001
Copy link
Author

@achapkowski
That's exactly what I did. Cntlm is the local proxy.
Thanks.

@achapkowski
Copy link
Collaborator

@lucksimo can you post your solution? All the steps to work around this issue? I think it would be a great wiki article as well because I'm sure there are other people who have this issue.

Thank you

@simoxu001
Copy link
Author

sorry for the late response @achapkowski , I'v been tied up on some emergency stuff.

Using a local proxy like cntml can help when using ArcREST behind enterprise proxy. It seems there is no way to explicitly input your windows credentials in some ArcREST functions although it allows users to provide proxy_url and proxy_port. Since local proxy saves the credentials in its config file, you don't need to provide the credentials with the proxy server name and port number, and it's safer, bonus.

Here is a very good online article about installing cntml.
http://stormpoopersmith.com/2012/03/20/using-applications-behind-a-corporate-proxy/

Hope this can help people who have the same issue.

@achapkowski
Copy link
Collaborator

@lucksimo - Thanks for posting this! I'm sure it will help lots of people.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants