在python请求中使用post时获取requests.exceptions.SLE错误



我使用请求将数据发布到这个Auth0 api,下面是代码

@receiver(post_save, sender=OrgUser)
def user_is_created(sender, instance, created, **kwargs):
if created:
full_name = instance.full_name
first_name = instance.first_name
last_name = instance.last_name
email = instance.email
cell = instance.cell
password = ''.join(random.choices(string.ascii_uppercase + string.digits, k=15))
url = "https://127.0.0.1:8080/dbconnections/signup"
user_data = {
'client_id': config("APP_CLIENT_ID"),
'connection': config("DATABASE_CONNECTION"),
'full_name': full_name,
'first_name': first_name,
'last_name': last_name,
'email': email,
'password': password,     
'cell': cell,
}
r = requests.post(url, json = user_data, headers = {'User-agent': 'your bot 0.1'}, verify=False)
else:
pass

我收到以下错误信息

requests.exceptions.SSLError: HTTPSConnectionPool(host='127.0.0.1', port=8080): Max retries exceeded with url: /dbconnections/signup (Caused by SSLError(SSLError(1, '[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:1091)')))

我寻找类似的问题,但到目前为止没有任何帮助。

在运行代码后,我在终端中也有这两行

[07/Oct/2022 15:08:12] code 400, message Bad HTTP/0.9 request type ('x16x03x01x00Ýx01x00x00Ùx03x03}x9aPx98|9x9eÁ±XÀx97C)G@¶x880Gx80õx87u÷,'"µx96ü@x00x00bÀ0À,À/À+x00x9fx00x9eÀ2À.À1À-x00¥x00¡x00¤x00')
[07/Oct/2022 15:08:12] You're accessing the development server over HTTPS, but it only supports HTTP.

当环境中存在过时版本的pyOpenSSL时,可能会出现此错误。如果pyOpenSSL版本较旧,则卸载该版本并重新安装新版本可能是值得的。

类似问题:https://github.com/psf/requests/issues/4246

我修复了它。在我的url中,我而不是

"https://127.0.0.1:8080/dbconnections/signup"

我不得不放

"https://my-auth0-domain/dbconnections/signup"

最新更新