407 需要代理认证

2 投票
1 回答
24130 浏览
提问于 2025-04-17 17:52

我在我的Django应用中尝试使用django-social-auth。虽然在我的Mac上一切正常,但当我在Windows机器上使用相同的代码时,出现了407代理认证失败的错误。

 <urlopen error Tunnel connection failed: 407 Proxy Authentication Required ( Forefront 

TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )>

任何帮助都将非常感谢。

1 个回答

2
Forefront TMG requires authorization to fulfill the request

看起来你的机器被设置成需要通过一个代理服务器来发送外部流量(在这个例子中是微软的TMG)。当用户尝试用你的应用进行身份验证时,Django会试图连接到另一个服务来验证用户,但因为代理的设置,它无法到达那个服务。

因为调用 urlopen 的代码可能是在 django-social-auth 里,所以你可能不想直接修改它来使用代理。你可以尝试设置一个 http_proxy 的环境变量(具体可以参考 这个回答),这样可以让所有的 urllib 请求都通过代理,或者你也可以选择禁用你的网站服务器的代理认证。

撰写回答