如何防止谷歌日历请求收到谷歌联系人回复

时间:2015-09-03 08:57:09

标签: c# google-calendar-api google-api-client google-api-dotnet-client

我们多年来一直通过c#客户端库(Google.Apis.Calendar.v3.1.9.2.1330)成功使用Google Contact和Calendar API。最近发生了一个不寻常的错误。似乎日历API调用正在获取联系API响应(请参阅下文)。有没有人遇到过这个问题并有解决方案来防止它再次发生?

编辑: 包括代码段:

using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Http;
using Google.Apis.Services;

...

var eventList = service.Events.List(calendarListEntry.Id);
eventList.TimeMin = dateFrom;
eventList.TimeMax = dateTo;
eventList.SingleEvents = true;
var events = eventList.Execute().Items;
编辑:所以这是一个发生这种情况的例子。我从日志中取出了任何敏感信息,但事件的顺序是。 1.我们看到两个成功的API请求和响应。 2.我们得到404响应,但奇怪的是,这会产生一个解析异常,好像响应包含xml或者至少有一些开头的'<&#;; 3.对同一URI的后续请求返回200

1.
    "63577099854207364450, Request https://www.googleapis.com/calendar/v3/users/me/calendarList, req auth:Bearer xxx, headers:User-Agent: Datahug google-api-dotnet-client/1.9.3.19379 (gzip)
    Authorization: Bearer xxx
    , Thread50"
    "63577099854637364450, Request https://www.googleapis.com/calendar/v3/calendars/eaxmple@domain.com/events?singleEvents=True&timeMax=2016-03-06T01:30:53.873Z&timeMin=2016-02-05T01:30:53.873Z, req auth:Bearer xxx, headers:User-Agent: Datahug google-api-dotnet-client/1.9.3.19379 (gzip)
    Authorization: Bearer xxx
    , Thread50"
    "63577099854207364450, Request https://www.googleapis.com/calendar/v3/users/me/calendarList, req auth:Bearer xxx, Thread41, result:StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Vary: Origin
      Vary: X-Origin
      X-Content-Type-Options: nosniff
      X-Frame-Options: SAMEORIGIN
      X-XSS-Protection: 1; mode=block
      Alternate-Protocol: 443:quic,p=1
      Alt-Svc: quic="":443""; p=""1""; ma=604800
      Transfer-Encoding: chunked
      Cache-Control: no-transform, must-revalidate, max-age=0, private
      Date: Sun, 06 Sep 2015 01:30:54 GMT
      Server: GSE
      Content-Type: application/json; charset=UTF-8
      Expires: Sun, 06 Sep 2015 01:30:54 GMT
    }"
    "63577099854637364450, Request https://www.googleapis.com/calendar/v3/calendars/eaxmple@domain.com/events?singleEvents=True&timeMax=2016-03-06T01:30:53.873Z&timeMin=2016-02-05T01:30:53.873Z, req **auth:Bearer xxx**, Thread29, result:StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Vary: Origin
      Vary: X-Origin
      X-Content-Type-Options: nosniff
      X-Frame-Options: SAMEORIGIN
      X-XSS-Protection: 1; mode=block
      Alternate-Protocol: 443:quic,p=1
      Alt-Svc: quic="":443""; p=""1""; ma=604800
      Transfer-Encoding: chunked
      Cache-Control: no-transform, must-revalidate, max-age=0, private
      Date: Sun, 06 Sep 2015 01:30:54 GMT
      Server: **GSE**
      Content-Type: application/json; charset=UTF-8
      Expires: Sun, 06 Sep 2015 01:30:54 GMT
    }"
    "63577099856222364450, Request https://www.googleapis.com/calendar/v3/users/me/calendarList, req auth:Bearer yyy, headers:User-Agent: Datahug google-api-dotnet-client/1.9.3.19379 (gzip)
    Authorization: Bearer yyy
    , Thread50"
2.    "63577099856222364450, Request https://www.googleapis.com/calendar/v3/users/me/calendarList, req **auth:Bearer yyy**, Thread42, result:StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Connection: close
      Date: Sun, 06 Sep 2015 01:30:56 GMT
      Server: **GFE/2.0**
      Content-Length: 1527
      Content-Type: text/html; charset=UTF-8
    }"
    An Error occurred, but the error response could not be deserialized|The service calendar has thrown an exception: Google.GoogleApiException: An Error occurred, but the error response could not be deserialized ---> Newtonsoft.Json.JsonReaderException: **Unexpected character encountered while parsing value: <.** Path '', line 0, position 0.
       at Newtonsoft.Json.JsonTextReader.ParseValue()
       at Newtonsoft.Json.JsonTextReader.ReadInternal()
       at Newtonsoft.Json.JsonTextReader.Read()
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
       at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
       at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
       at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
       at Google.Apis.Json.NewtonsoftJsonSerializer.Deserialize[T](String input) in c:\ApiaryDotnet\default\Src\GoogleApis.Core\Apis\Json\NewtonsoftJsonSerializer.cs:line 120
       at Google.Apis.Services.BaseClientService.<DeserializeError>d__8.MoveNext() in c:\ApiaryDotnet\default\Src\GoogleApis\Apis\Services\BaseClientService.cs:line 286
       --- End of inner exception stack trace ---
       at Google.Apis.Requests.ClientServiceRequest`1.Execute() in c:\ApiaryDotnet\default\Src\GoogleApis\Apis\Requests\ClientServiceRequest.cs:line 102
       at DataIntegration.Services.Google.ImportGmailCalenderService.ImportGmailCalendars(DateTime dateFrom, DateTime dateTo, Boolean validateResultsAreForCorrectAccount, ISet`1 internalDomainUrls, String email, String account) in c:\buildworkspaces\WebApp-BuildUnitTest-NextRelease\NextRelease\DataIntegration\Services\Google\ImportGmailCalendarService.cs:line 59


3.    "63577099858032364450, Request https://www.googleapis.com/calendar/v3/users/me/calendarList, req auth:Bearer yyy, headers:User-Agent: Datahug google-api-dotnet-client/1.9.3.19379 (gzip)
    Authorization: Bearer yyy
    , Thread50"
    "63577099858032364450, Request https://www.googleapis.com/calendar/v3/users/me/calendarList, req auth:Bearer yyy, Thread39, result:StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Vary: Origin
      Vary: X-Origin
      X-Content-Type-Options: nosniff
      X-Frame-Options: SAMEORIGIN
      X-XSS-Protection: 1; mode=block
      Alternate-Protocol: 443:quic,p=1
      Alt-Svc: quic="":443""; p=""1""; ma=604800
      Transfer-Encoding: chunked
      Cache-Control: no-transform, must-revalidate, max-age=0, private
      Date: Sun, 06 Sep 2015 01:30:58 GMT
      Server: GSE
      Content-Type: application/json; charset=UTF-8
      Expires: Sun, 06 Sep 2015 01:30:58 GMT
    }"

需要注意的几点:在有问题的请求/响应之前,auth bearer token已经被更改了。错误响应中的服务器与成功响应中的服务器不同。

0 个答案:

没有答案
相关问题