Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从geo_API中的python代码解决与tomcat身份验证相关的错误?_Python_Api_Tomcat_Sentinelsat - Fatal编程技术网

如何从geo_API中的python代码解决与tomcat身份验证相关的错误?

如何从geo_API中的python代码解决与tomcat身份验证相关的错误?,python,api,tomcat,sentinelsat,Python,Api,Tomcat,Sentinelsat,由于有一项任务是使用SentinelAPI获取卫星图像,因此当我参照文档键入以下代码时,下面的SentinelAPI类的####处似乎发生了错误 api=SentinelAPI(用户、密码,'https://scihub.copernicus.eu/dhus) > sentinelsat.sentinel.SentinelAPIError:HTTP状态401未经授权: HTTP状态401--访问此资源需要完全身份验证 **类型**状态报告 **消息**访问此资源需要完全身份验证 **说明**此请

由于有一项任务是使用SentinelAPI获取卫星图像,因此当我参照文档键入以下代码时,下面的SentinelAPI类的####处似乎发生了错误

api=SentinelAPI(用户、密码,'https://scihub.copernicus.eu/dhus)

>

sentinelsat.sentinel.SentinelAPIError:HTTP状态401未经授权:

HTTP状态401--访问此资源需要完全身份验证 **类型**状态报告

**消息**访问此资源需要完全身份验证

**说明**此请求需要HTTP身份验证


ApacheTomcat/8.0.36 我想寻求解决这个问题的办法

    """Check that the response from server has status code 2xx and that the response is valid JSON.
    """
    # Prevent requests from needing to guess the encoding
    # SciHub appears to be using UTF-8 in all of their responses
    response.encoding = "utf-8"
    try:
        response.raise_for_status()
        if test_json:
            response.json()
    except (requests.HTTPError, ValueError):
        msg = "Invalid API response."
        try:
            msg = response.headers["cause-message"]
            
        except:
            try:
                msg = response.json()["error"]["message"]["value"]
                
            except:
                if not response.text.strip().startswith("{"):
                    try:
                        h = html2text.HTML2Text()
                        h.ignore_images = True
                        h.ignore_anchors = True
                        msg = h.handle(response.text).strip()
                        ################# print(msg)
                    except:
                        pass
        api_error = SentinelAPIError(msg, response)
        # Suppress "During handling of the above exception..." message
        # See PEP 409
        api_error.__cause__ = None
        raise api_error```