尝试调用 google-api oauth2 时,请求缺少所需的身份验证凭据

时间:2021-04-21 00:01:36

标签: python python-3.x google-api

我像这样通过邮递员中的有效载荷发送我的 access_token,以在我的后端获取电子邮件、姓名等信息。:

{
    "access_token": "my-google-acces-token"
}

在后端,我尝试将此 access_token 发送到这样的谷歌请求:

response = requests.get('https://www.googleapis.com/oauth2/v2/userinfo',
                        headers={'Authorization': f'Bearer {access_token_data}'})

我得到了这个回复:

{
      "error": {
        "code": 401,
        "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
        "status": "UNAUTHENTICATED"
      }
    }

我做错了什么?我的 google-access-token 是对的

0 个答案:

没有答案