HTTP错误401:间歇性授权要求

时间:2015-02-05 16:35:27

标签: python security ubuntu firewall

这更像是一个与linux /安全相关的问题(比Python的urllib2认证问题)

我的设置是:

  1. 我在公司的公司网络中运行Ubuntu服务器

  2. 我注意到当我尝试通过浏览器(chrome或firefox)访问互联网时,我会间歇性地重定向到公司的安全页面,询问我公司的凭据。

  3. Ubuntu服务器的防火墙已被禁用。

  4. 我不确定原因,但是当我尝试运行以下脚本(从互联网上获取数据,甚至是google.com)时,由于401 Authorization Required Error,此脚本会间歇性地失败。一旦发生这种情况,我就必须打开浏览器(显然是通过VNC访问),然后转到任何页面,我必须输入我的凭据。一旦我做了,那么脚本运行一段时间就好了。过了一会儿,它再次因401错误而失败。

  5. 脚本

    import urllib2
    url = 'http://nominatim.openstreetmap.org/search.php?countrycodes=us&state=colorado&street=6900+W+25th+Ave&format=json&addressdetails=1&polygon_geojson=1'
    request = urllib2.Request(url)
    response = urllib2.urlopen(request).read()
    print response
    
    Traceback (most recent call last):
      File "/home/amit/workspace/clink/device_polling/mydb/dbmanager.py", line 1554, in _poll_device
        self.update__device_geoloc(deviced_alldb, mydbc, hpnac, logobj)
      File "/home/amit/workspace/clink/device_polling/mydb/dbmanager.py", line 1387, in update__device_geoloc
        geoinfo = get_coordinates_geolocation(state=state, city=city, street=street, countrycodes=countrycodes)
      File "/home/amit/workspace/clink/device_polling/utils/utils.py", line 386, in get_coordinates_geolocation
        response = urllib2.urlopen(req)
      File "/miniconda/envs/py_env_clink/lib/python2.7/urllib2.py", line 127, in urlopen
        return _opener.open(url, data, timeout)
      File "/miniconda/envs/py_env_clink/lib/python2.7/urllib2.py", line 410, in open
        response = meth(req, response)
      File "/miniconda/envs/py_env_clink/lib/python2.7/urllib2.py", line 523, in http_response
        'http', request, response, code, msg, hdrs)
      File "/miniconda/envs/py_env_clink/lib/python2.7/urllib2.py", line 442, in error
        result = self._call_chain(*args)
      File "/miniconda/envs/py_env_clink/lib/python2.7/urllib2.py", line 382, in _call_chain
        result = func(*args)
      File "/miniconda/envs/py_env_clink/lib/python2.7/urllib2.py", line 629, in http_error_302
        return self.parent.open(new, timeout=req.timeout)
      File "/miniconda/envs/py_env_clink/lib/python2.7/urllib2.py", line 410, in open
        response = meth(req, response)
      File "/miniconda/envs/py_env_clink/lib/python2.7/urllib2.py", line 523, in http_response
        'http', request, response, code, msg, hdrs)
      File "/miniconda/envs/py_env_clink/lib/python2.7/urllib2.py", line 448, in error
        return self._call_chain(*args)
      File "/miniconda/envs/py_env_clink/lib/python2.7/urllib2.py", line 382, in _call_chain
        result = func(*args)
      File "/miniconda/envs/py_env_clink/lib/python2.7/urllib2.py", line 531, in http_error_default
        raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    HTTPError: HTTP Error 401: Authorization Required
    

    我不明白为什么会这样?有没有安全人员知道我应该在这看什么?我确信它与我的公司防火墙有关,它会定期向我的ubuntu服务器请求密码

0 个答案:

没有答案