请求具有无效的身份验证凭据-Google Calendar API

时间:2020-07-19 18:27:57

标签: oauth-2.0 postman google-calendar-api google-oauth

我正在尝试使用Postman向Google Calendar API发送请求。遵循以下Google文档: https://developers.google.com/calendar/v3/reference/?apix=true

我在做:

GET  https://www.googleapis.com/calendar/v3/calendars/{my_calendar_id_here}

在“邮递员授权”选项卡上,我指定我想使用OAuth 2.0,并且还放置了访问令牌(我用来从代码进行Calendar API调用,效果很好)。但是,邮递员的回应如下:

{
  "error": {
    "code": 401,
    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "errors": [
      {
        "message": "Invalid Credentials",
        "domain": "global",
        "reason": "authError",
        "location": "Authorization",
        "locationType": "header"
      }
    ],
    "status": "UNAUTHENTICATED"
  }
} 

我真的不明白我在做错什么,而其他答案似乎并没有针对我的特定情况。如果有人能指出我在做什么错,我将不胜感激。

1 个答案:

答案 0 :(得分:0)

我建议在Google's OAuth 2.0 Playground中复制请求。然后使用已确认有效的访问令牌对Postman进行故障排除。

对于邮递员,您还可以将访问令牌作为请求标头传递,如果这样可以解决问题。

邮递员标题标签输入:

| Key           | Value                 |
|---------------|-----------------------|
| Authorization | Bearer {access_token} |