我正在使用该库google-auth~=2.28.1
在我的网络应用程序中启用“使用 Google 登录”。登录在我的本地计算机和测试服务器(hetzner)上工作,但在产品服务器(也是hetzner)上它最近停止工作。
这是我的 python web 应用程序抛出异常的部分:
id_info = id_token.verify_oauth2_token(
credential, requests.Request(), auth_config.google_client_id
)
这是错误:
google.auth.exceptions.TransportError: Could not fetch certificates at https://www.googleapis.com/oauth2/v1/certs
Web 应用程序在扩展的 docker 容器中运行python:3.10
。
在我读完这篇ServerFault 帖子后,我尝试curl
从服务器和 Docker 容器中使用 IPv4 和 IPv6。与 SF 帖子相反,IPv6 可以工作,而 IPV4 则不行。
curl -4 'https://www.googleapis.com/oauth2/v1/certs'
截断的输出:
<p><b>403.</b> <ins>That’s an error.</ins>
<p>Your client does not have permission to get URL <code>/oauth2/v1/certs</code> from this server. <ins>That’s all we know.</ins>
curl -6 'https://www.googleapis.com/oauth2/v1/certs'
截断的输出:
{"6f9777a685907798ef794062c00b65d66c240b1b": "-----BEGIN CERT....}
我过去遇到过这个问题,几天后它就自行解决了,但我想要一个更永久的解决方案。