title: Google Calendar incremental sync with initial time_max
body: <p>I'm trying to sync a google calendar with my rails application. I've been following the documentation provided by Google:
  <a href="https://developers.google.com/google-apps/calendar/v3/sync" rel="noreferrer">Synchronize Resources Efficiently</a>. </p>
  
  <p>My goal is to only sync events one year into the future and split up recurring events into single events so that I don't have to deal with the complexity of recurrence rules and creating child events for recurring parent events. </p>
  
  <p>During the initial sync I set the time_max to be 1 year in the future and during the initial sync I only get recurring events up to one year into the future. </p>
  
  <p>When I perform an incremental sync I pass the sync token and expect to get recurring events limited to within one year of the initial sync's time_max, but this is not what I'm seeing. I am seeing events well past one year (~10 years). </p>
  
  <p>During the incremental sync I'm unable to set a time_max as I get this <strong>expected</strong> error from Google. </p>
  
  <blockquote>
    <p>Caught error syncTokenWithRequestRestrictions: Sync token cannot be used with other request restrictions.</p>
  </blockquote>
  
  <p>Here's the code I use to sync events from google into my application</p>
  
  <pre><code>def sync_from_google
      next_page_token = nil
  
      begin
        if sync_token.nil? # full sync
          response = @calendar_service.list_events(google_id,
            time_min: Time.now.utc.strftime("%FT%TZ"),
            time_max: 1.year.from_now.utc.strftime("%FT%TZ"),
            single_events: true)
        else # incremental sync
          response = @calendar_service.list_events(google_id,
            sync_token: sync_token,
            page_token: next_page_token,
            single_events: true)
        end
  
        response.items.each do |gevent|
          GoogleCalendarEvent.create_event(self.id, gevent, nil)
        end
        next_page_token = response.next_page_token
  
      rescue Google::Apis::ClientError =&gt; error
        if error.status_code == 410
          self.unsync
        end
      end while (response.next_sync_token.nil?)
  
      update_attributes(synced: true, sync_token: response.next_sync_token)
  end
  </code></pre>
  
  <p>Am I being a dummy and missing something obvious?</p>
  
  <p>Should sync_tokens provided by the initial sync store the time range of desired events? </p>
  
  <p>Is there some other way that I can limit the incremental sync's time range?</p>