当前位置: 首页 > 知识库问答 >
问题:

Google日历API 401“无效凭据”

云和硕
2023-03-14

一些(但不是全部)Google帐户在尝试访问Google日历API时始终响应401,尽管Tokeninfo告诉我我正在使用的访问令牌具有适当的范围(请参阅下面的curl输出)。我可以使用刷新令牌成功获取新的访问令牌,但日历api继续到401。

有人知道为什么会发生这种情况吗?

$ curl -v https://www.googleapis.com/oauth2/v3/tokeninfo?access_token=[redacted]
*   Trying 216.58.195.74...
* Connected to www.googleapis.com (216.58.195.74) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.googleapis.com
* Server certificate: Google Internet Authority G2
* Server certificate: GeoTrust Global CA
> GET /oauth2/v3/tokeninfo?access_token=[redacted] HTTP/1.1
> Host: www.googleapis.com
> User-Agent: curl/7.49.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: Mon, 01 Jan 1990 00:00:00 GMT
< Date: Tue, 18 Oct 2016 22:00:45 GMT
< Vary: X-Origin
< Content-Type: application/json; charset=UTF-8
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: GSE
< Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
< Accept-Ranges: none
< Vary: Origin,Accept-Encoding
< Transfer-Encoding: chunked
<
{
 "azp": "[redacted].apps.googleusercontent.com",
 "aud": "[redacted].apps.googleusercontent.com",
 "sub": "[redacted]",
 "scope": "https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/calendar",
 "exp": "1476831626",
 "expires_in": "3581",
 "email": "[redacted]",
 "email_verified": "true",
 "access_type": "offline"
}
* Connection #0 to host www.googleapis.com left intact


$ curl -v https://www.googleapis.com/calendar/v3/users/me/calendarList?access_token=[redacted]
*   Trying 216.58.195.74...
* Connected to www.googleapis.com (216.58.195.74) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.googleapis.com
* Server certificate: Google Internet Authority G2
* Server certificate: GeoTrust Global CA
> GET /calendar/v3/users/me/calendarList?access_token=[redacted] HTTP/1.1
> Host: www.googleapis.com
> User-Agent: curl/7.49.1
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Vary: X-Origin
< WWW-Authenticate: Bearer realm="https://accounts.google.com/", error=invalid_token
< Content-Type: application/json; charset=UTF-8
< Date: Tue, 18 Oct 2016 22:01:14 GMT
< Expires: Tue, 18 Oct 2016 22:01:14 GMT
< Cache-Control: private, max-age=0
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: GSE
< Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
< Accept-Ranges: none
< Vary: Origin,Accept-Encoding
< Transfer-Encoding: chunked
<
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "authError",
    "message": "Invalid Credentials",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Invalid Credentials"
 }
}
* Connection #0 to host www.googleapis.com left intact

共有2个答案

周洋
2023-03-14

即使启用了Google日历,我的客户也会发生这种情况。

原来他们已经让免费的14天试用到期,并且没有输入信用卡付款。一旦他们解决了这个问题,错误就消失了。

尚棋
2023-03-14

我创建了一个谷歌应用程序用户,其子组织关闭了谷歌日历,从而重现了这种情况。Google仍将允许用户授予日历访问权限,并将指示已授予该范围,但当您尝试使用访问令牌调用任何Google日历APIendpoint时,将按照所述方式进行401。

Google,当请求访问已被管理员关闭的应用程序时,请将错误消息弄清楚或阻止初始范围授予!

 类似资料:
  • 我在使用Java客户端库(google-api客户端版本1.13.2-beta,google-api服务-日历版本v3-rev 26-1.13.2-beta)对Google日历API v3进行身份验证时遇到问题。 我们有一个marketplace应用程序,安装该应用程序应为其提供读取(和写入)Google日历事件所需的凭据。 我们使用2腿OAuth 1.0,带有Hmac,这意味着不需要代币。这正是

  • 我想使用脚本化方法(可能是通过)curl,从驱动器api访问一些简单的信息,例如创建日期。从本质上讲,我想在他们的Web界面中编写我可以做的事情:https://developers.google.com/drive/api/v3/reference/files/list。 我一直在使用curl命令,他们在上面的链接的查询中公开该命令: 我为此创建了一个API密钥(目前不受限制)。并使用此应用程序

  • 我有一个问题与Google plus访问令牌。它有时给我“无效凭据”错误消息,有时相同的标记显示为活动。 以下是步骤 是否有验证刷新令牌的方法?

  • 我是新手,但我想将google API与PHP结合使用,但它不起作用。我已经创建了

  • 我试图创建一个谷歌日历服务帐户。 以下是我的证件: 以下是我的服务帐户定义(已启用服务帐户的站点范围委托):