我正在从那里使用后端进行Google身份验证: https://developers.google.com/identity/sign-in/android/backend-auth
似乎有些过时了,最奇怪的是,有一行:
idinfo = id_token.verify_oauth2_token(token, requests.Request(), CLIENT_ID)
在实现中,您可以看到在嵌套函数调用中,相同的请求对象位于该位置:
def _fetch_certs(request, certs_url):
"""Fetches certificates.
Google-style cerificate endpoints return JSON in the format of
``{'key id': 'x509 certificate'}``.
Args:
request (google.auth.transport.Request): The object used to make
HTTP requests.
certs_url (str): The certificate endpoint URL.
Returns:
Mapping[str, str]: A mapping of public key ID to x.509 certificate
data.
"""
response = request(certs_url, method='GET')
request是一个对象,即使文档声称如此,它也将其用作功能。我得到的错误是:
TypeError:“请求”对象不可调用
在那里应该更改什么?
答案 0 :(得分:0)
很可能您正在调用错误的python请求库。
如果您需要区分2个可用请求库。
from google.auth.transport import requests as google_auth_request
import requests
req = google_auth_request.Request()
idinfo = id_token.verify_oauth2_token(token, req, CLIENT_ID)
请参阅:https://google-auth.readthedocs.io/en/latest/reference/google.oauth2.id_token.html