Calendar Events Notification not received on server

百般思念 提交于 2019-11-28 02:22:01

问题


I'm trying to watch google calendar events.

I have written this code:

  def watch_calendar_event
    result = @client.execute(
      api_method: @calendar_api.events.watch,
      parameters: { calendarId: 'primary' },
      body_object: watch_hash,
      headers: {'Content-Type' => 'application/json'}
    )
    if result.status == 200
      watch_data = result.data
      @calendar.update booking_expiration: watch_data.expiration, booking_id: watch_data.id, booking_resource_id: watch_data.resourceId, booking_resource_uri: watch_data.resourceUri, watching_event: true
    end
  rescue Exception => ex
    raise GoogleCalendarException, ex.message
  end

And I'm getting a 200 success message with other details like booking_id, resource_id and resourceUri.

But when I create a new event on the google calendar I'm not getting any notification on my server.

Any idea what could be the reason.

Also note I have done everything they have asked here and I have also configured an https server for this.

My webhook URL is like: https://dev.application.com/notifications & I have also opened routes for this.

My route:

post '/notifications', to: "calendars#calendar_events_watch", defaults: {format: 'json'}

My controller code:

  def calendar_events_watch
    logger.info "Received an event notification. **************************#{request.env.inspect}"
    if request.env["HTTP_X_GOOG_RESOURCE_STATE"] != "sync"
      channel_id = request.env["HTTP_X_GOOG_CHANNEL_ID"]
      resource_id = request.env["HTTP_X_GOOG_RESOURCE_ID"]
      # resource_uri = request.env["HTTP_X_GOOG_RESOURCE_URI"]
      # channel_token = request.env["HTTP_X_GOOG_CHANNEL_TOKEN"]
    end
    render status: 200
  end

来源:https://stackoverflow.com/questions/34654504/calendar-events-notification-not-received-on-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!