Java 谷歌日历事件观察

Java 谷歌日历事件观察,java,calendar,google-api-java-client,google-calendar-api,Java,Calendar,Google Api Java Client,Google Calendar Api,我在使用谷歌日历API时遇到问题。我已经设置了客户端ID和客户端密码,并且能够从用户那里获得访问和刷新令牌。此外,在中验证域。如下所示,我能够使用API插入一个新事件。但是,调用事件监视失败,并显示401未经授权的消息。下面我已经包括了HTTP日志 我在用电话 有人知道我为什么会收到401未经授权的回复吗 创建一个新事件 CONFIG - Total: 382 bytes CONFIG - {"attendees":[{"additionalGuests":0,"displayName":"So

我在使用谷歌日历API时遇到问题。我已经设置了客户端ID和客户端密码,并且能够从用户那里获得访问和刷新令牌。此外,在中验证域。如下所示,我能够使用API插入一个新事件。但是,调用事件监视失败,并显示401未经授权的消息。下面我已经包括了HTTP日志

我在用电话

有人知道我为什么会收到401未经授权的回复吗

创建一个新事件

CONFIG - Total: 382 bytes
CONFIG - {"attendees":[{"additionalGuests":0,"displayName":"SomeName","email":"somename@somedomain.tld","optional":false}],"description":"some description","end":{"dateTime":"2018-05-04T20:00:00.000+02:00"},"extendedProperties":{"private":{"someextprop":"someextvalue"}},"start":{"dateTime":"2018-05-04T19:00:00.000+02:00"},"summary":"Some summary"}
(1/8) CONFIG - -------------- REQUEST  --------------
(2/8) POST https://www.googleapis.com/calendar/v3/calendars/primary/events?sendNotifications=true
(3/8) Accept-Encoding: gzip
(4/8) Authorization: Bearer [TOKEN]
(5/8) User-Agent: SomeApp Google-API-Java-Client Google-HTTP-Java-Client/1.23.0 (gzip)
(6/8) Content-Type: application/json; charset=UTF-8
(7/8) Content-Encoding: gzip
(8/8) Content-Length: 269
CONFIG - curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: Bearer [TOKEN]' -H 'User-Agent: SomeApp Google-API-Java-Client Google-HTTP-Java-Client/1.23.0 (gzip)' -H 'Content-Type: application/json; charset=UTF-8' -H 'Content-Encoding: gzip' -d '@-' -- 'https://www.googleapis.com/calendar/v3/calendars/primary/events?sendNotifications=true' << $$$
CONFIG - Total: 382 bytes
CONFIG - {"attendees":[{"additionalGuests":0,"displayName":"SomeName","email":"somename@somedomain.tld","optional":false}],"description":"some description","end":{"dateTime":"2018-05-04T20:00:00.000+02:00"},"extendedProperties":{"private":{"someextprop":"someextvalue"}},"start":{"dateTime":"2018-05-04T19:00:00.000+02:00"},"summary":"Some summary"}
(1/17) CONFIG - -------------- RESPONSE --------------
(2/17) HTTP/1.1 200 OK
(3/17) Transfer-Encoding: chunked
(4/17) Alt-Svc: hq=":443"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="43,42,41,39,35"
(5/17) Server: GSE
(6/17) X-Content-Type-Options: nosniff
(7/17) Pragma: no-cache
(8/17) Date: Fri, 04 May 2018 16:24:06 GMT
(9/17) X-Frame-Options: SAMEORIGIN
(10/17) Cache-Control: no-cache, no-store, max-age=0, must-revalidate
(11/17) ETag: "3050902092840000"
(12/17) Content-Encoding: gzip
(13/17) Vary: X-Origin
(14/17) Vary: Origin
(15/17) Expires: Mon, 01 Jan 1990 00:00:00 GMT
(16/17) X-XSS-Protection: 1; mode=block
(17/17) Content-Type: application/json; charset=UTF-8
CONFIG - Total: 1.070 bytes
(1/44) CONFIG - {[GOOGLE EVENT JSON, REMOVED FOR BREVITY]}
CONFIG-总计:382字节
配置-{“与会者”:[{“additionalGuests”:0,“displayName”:“SomeName”,“email”:somename@somedomain.tld“,”可选“:false}],”description“:”一些描述“,”结束“{”日期时间“:”2018-05-04T20:00:00.000+02:00“,”扩展属性“{”私有“:{”somextprop:”someextvalue“}”,开始“,”日期时间“:”2018-05-04T19:00:00.000+02:00“,”摘要“:”一些摘要“}”
(1/8)配置-----------------请求--------------
(2/8)员额https://www.googleapis.com/calendar/v3/calendars/primary/events?sendNotifications=true
(3/8)接受编码:gzip
(4/8)授权:持票人[代币]
(5/8)用户代理:SomeApp谷歌API Java客户端谷歌HTTP Java客户端/1.23.0(gzip)
(6/8)内容类型:application/json;字符集=UTF-8
(7/8)内容编码:gzip
(8/8)内容长度:269

CONFIG-curl-v--compressed-X POST-H'接受编码:gzip'-H'授权:Bearer[TOKEN]'-H'用户代理:SomeApp谷歌API Java客户端谷歌HTTP Java客户端/1.23.0(gzip)'-H'内容类型:application/json;charset=UTF-8'-H'内容编码:gzip'-d'@-'--'https://www.googleapis.com/calendar/v3/calendars/primary/events?sendNotifications=true所以我们终于找到了解决办法。域验证出错。因此,进行配置的一方将在中使用,而不是仅使用

我有如下错误消息。这表明用于回调的url/域存在错误。如果得到这样的消息,而不是空的401响应,那会很有帮助

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "push.webhookUrlUnauthorized",
    "message": "Unauthorized WebHook callback channel: XXX"
   }
  ],
  "code": 401,
  "message": "Unauthorized WebHook callback channel: XXX"
 }
}
(1/6) CONFIG - -------------- REQUEST  --------------
(2/6) POST https://accounts.google.com/o/oauth2/token
(3/6) Accept-Encoding: gzip
(4/6) User-Agent: Google-HTTP-Java-Client/1.23.0 (gzip)
(5/6) Content-Type: application/x-www-form-urlencoded; charset=UTF-8
(6/6) Content-Length: 229
CONFIG - curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'User-Agent: Google-HTTP-Java-Client/1.23.0 (gzip)' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -d '@-' -- 'https://accounts.google.com/o/oauth2/token' << $$$
CONFIG - Total: 229 bytes
CONFIG - grant_type=refresh_token&refresh_token=[REFRESHTOKEN]client_secret=[CLIENTSECRET]
(1/15) CONFIG - -------------- RESPONSE --------------
(2/15) HTTP/1.1 200 OK
(3/15) Transfer-Encoding: chunked
(4/15) Alt-Svc: hq=":443"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="43,42,41,39,35"
(5/15) Server: ESF
(6/15) X-Content-Type-Options: nosniff
(7/15) Pragma: no-cache
(8/15) Date: Fri, 04 May 2018 16:24:06 GMT
(9/15) X-Frame-Options: SAMEORIGIN
(10/15) Cache-Control: no-cache, no-store, max-age=0, must-revalidate
(11/15) Content-Disposition: attachment; filename="json.txt"; filename*=UTF-8''json.txt
(12/15) Content-Encoding: gzip
(13/15) Expires: Mon, 01 Jan 1990 00:00:00 GMT
(14/15) X-XSS-Protection: 1; mode=block
(15/15) Content-Type: application/json; charset=utf-8
CONFIG - Total: 206 bytes
(1/5) CONFIG - {
(2/5)   "access_token" : "[TOKEN]",
(3/5)   "expires_in" : 3600,
(4/5)   "token_type" : "Bearer"
(5/5) }
CONFIG - Total: 140 bytes
CONFIG - {"address":"https://mysubdomain.mydomain.com/calendar-notification","id":"8bc11345-802b-4f18-bb3b-4e5c0abc53e2","type":"web_hook"}
(1/8) CONFIG - -------------- REQUEST  --------------
(2/8) POST https://www.googleapis.com/calendar/v3/calendars/primary/events/watch
(3/8) Accept-Encoding: gzip
(4/8) Authorization: Bearer [TOKEN]
(5/8) User-Agent: SomeApp Google-API-Java-Client Google-HTTP-Java-Client/1.23.0 (gzip)
(6/8) Content-Type: application/json; charset=UTF-8
(7/8) Content-Encoding: gzip
(8/8) Content-Length: 137
CONFIG - curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: Bearer [TOKEN]' -H 'User-Agent: SomeApp Google-API-Java-Client Google-HTTP-Java-Client/1.23.0 (gzip)' -H 'Content-Type: application/json; charset=UTF-8' -H 'Content-Encoding: gzip' -d '@-' -- 'https://www.googleapis.com/calendar/v3/calendars/primary/events/watch' << $$$
CONFIG - Total: 140 bytes
CONFIG - {"address":"https://mysubdomain.mydomain.com/calendar-notification","id":"8bc11345-802b-4f18-bb3b-4e5c0abc53e2","type":"web_hook"}
(1/16) CONFIG - -------------- RESPONSE --------------
(2/16) HTTP/1.1 401 Unauthorized
(3/16) Transfer-Encoding: chunked
(4/16) Alt-Svc: hq=":443"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="43,42,41,39,35"
(5/16) Server: GSE
(6/16) X-Content-Type-Options: nosniff
(7/16) WWW-Authenticate: Bearer realm="https://accounts.google.com/", error=invalid_token
(8/16) Date: Fri, 04 May 2018 16:24:06 GMT
(9/16) X-Frame-Options: SAMEORIGIN
(10/16) Cache-Control: private, max-age=0
(11/16) Content-Encoding: gzip
(12/16) Vary: X-Origin
(13/16) Vary: Origin
(14/16) Expires: Fri, 04 May 2018 16:24:06 GMT
(15/16) X-XSS-Protection: 1; mode=block
(16/16) Content-Type: application/json; charset=UTF-8
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "push.webhookUrlUnauthorized",
    "message": "Unauthorized WebHook callback channel: XXX"
   }
  ],
  "code": 401,
  "message": "Unauthorized WebHook callback channel: XXX"
 }
}