You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Python requests.post调用Auth0 API时遭遇requests.exceptions.SSLError

问题解决:SSL错误(UNKNOWN_PROTOCOL)与HTTP/HTTPS协议不匹配

问题根源

你的开发服务器仅支持HTTP协议,但代码中使用了HTTPS协议向127.0.0.1:8080发送请求,导致SSL握手失败触发SSLError。终端提示的You're accessing the development server over HTTPS, but it only supports HTTP直接点明了问题核心。

修复步骤

  1. 修正请求URL的协议:把代码里的url = "https://127.0.0.1:8080/dbconnections/signup"改为url = "http://127.0.0.1:8080/dbconnections/signup"
  2. 移除冗余的SSL验证参数:使用HTTP协议时,verify=False参数完全没必要,直接删除即可

修改后的代码片段:

@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))
        # 切换为HTTP协议
        url = "http://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,
        }
        # 移除verify=False参数
        r = requests.post(url, json = user_data, headers = {'User-agent': 'your bot 0.1'})
    else:
        pass

额外说明

  • 后续切换到生产环境(支持HTTPS的Auth0服务器)时,再把URL改回HTTPS协议,同时确保verify=True(默认值,无需显式设置)保障通信安全。
  • 终端里的Bad HTTP/0.9 request type错误是HTTPS请求被HTTP服务器解析导致的乱码,修复协议后该提示会自动消失。

内容的提问来源于stack exchange,提问作者Mike D Hovhannisyan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 17:15:49