首页 > 解决方案 > 使用 Flask-restful 创建 GET 函数但出现以下错误:[requests.exceptions.SSLError] [SSL: WRONG_VERSION_NUMBER]

问题描述

我目前正在开发一个使用 Flask-restful 的函数来调用一个从另一个站点获取二维码的 GET 函数。但出现以下错误:

requests.exceptions.SSLError: HTTPSConnectionPool(host='testing-site', port=443): 最大重试次数超出了 url: /testing/getQR?clientID={clientID}&responseType={response-type}&source=PC_Browser&redirectURI={redirect -url} (由 SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] 错误版本号 (_ssl.c:1122)')))

我的代码如下:

qr_request_body_web = {'clientID' : clientID, 'responseType' : 'code', 'source' : 'PC_Browser', 'redirectURI' : server_domain + authcallback_path}

def getQR():
response = requests.get('testing-site' + api_auth_getqr_path, params = qr_request_body_web, allow_redirects=True)
return redirect(response.url)

if __name__ == '__main__':
app.run(port=80, debug=True)

我可以在 Postman & Chrome 上调用 GET 函数,是否需要为 python 设置任何配置才能使其工作?非常感谢。

标签: python-3.xflaskopensslflask-restfulrestful-url

解决方案


确保浏览器中的“http://”和请求 URL 参数相同。如果不让它成为您在浏览器中看到的那个。让我知道这是否对您有帮助。


推荐阅读