War*_*ame 2 python google-authentication docker
我正在尝试将 google OAuth 用于我的网络应用程序。为此,我在我的 venv 和 Docker 构建期间安装了 google-api-python-client 和 google-auth 包(来自 requirements.txt)。尽管如此,当我运行我的应用程序时,它找不到请求模块,抱怨说:
flask.cli.NoAppException: While importing "debateit", an ImportError was raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/google/auth/transport/requests.py", line 23, in <module>
import requests
ImportError: No module named 'requests'
Run Code Online (Sandbox Code Playgroud)
导入如下:
from google.auth.transport import requests
Run Code Online (Sandbox Code Playgroud)
并使用如下:
idinfo = id_token.verify_oauth2_token(token, requests.Request(), app.config["GOOGLE_LOGIN_CLIENT_ID"])
Run Code Online (Sandbox Code Playgroud)
其他导入,如 id_token.verify_oauth2_token 工作正常。
我检查了我的 docker build,它说我已经正确地包含了 google-auth:
Installing collected packages: ... google-auth, httplib2, google-auth-httplib2, google-api-python-client
Successfully installed ... google-api-python-client-1.7.3 google-auth-1.5.0 google-auth-httplib2-0.0.3 httplib2-0.11.3 ...
Run Code Online (Sandbox Code Playgroud)
当我查看 venv 时,我可以清楚地看到 google.auth.transport.requests 模块,它只是在应用程序本身中不起作用。
我错过了什么?什么可能导致找不到此模块?
所以我发现出了什么问题 - 在 google.auth.transport.requests 模块中,他们尝试导入库“请求”。我没有安装这个库。我已经这样做了,现在可以使用了。
我遵循的指南:https : //developers.google.com/identity/sign-in/web/backend-auth没有提到您需要安装这个库。我误解了请求模块中请求的导入应该做什么。
| 归档时间: |
|
| 查看次数: |
4572 次 |
| 最近记录: |