谷歌日历事件与Rails应用程序集成



我使用google_apis_calendar_v3将Rails应用程序与谷歌日历集成。我已经为日历的增量事件同步实现并测试了推送通知。谷歌日历事件更改的推送通知在本地生产上运行良好,但推送通知无法在实时服务器上运行。

我遵循了本指南,并从谷歌搜索控制台验证了我的应用程序。

在account.rb:

def make_watch_event_channel
status = self.authorize_google_calendar_service
return if status != 200
callback_url = "#{APP_URL}/calendars/my_event_changes?my_account_id=#{self.id}"
time_min = DateTime.now.rfc3339
channel_id = SecureRandom.urlsafe_base64(10, false)
begin
@channel = Google::Apis::CalendarV3::Channel.new(address: callback_url, id: channel_id, type: "web_hook")
@webhook = @service.watch_event('primary', @channel, single_events: true, time_min: time_min)
self.calendars&.last&.update(resource_id: @webhook.resource_id, channel_id: channel_id)
rescue Google::Apis::AuthorizationError, Google::Apis::ClientError, Signet::AuthorizationError => e
Rails.logger.info "-------------------------"
Rails.logger.info e.message
Rails.logger.info "-------------------------"
end
end

修复了它。它实际上是nginx配置问题在/etc/nginx/sites-enabled/example.conf中,我正在重定向https://www.example.com"到"https://example.com"。所以我给了callback_url'https://example.com'第页,共页'https://www.example.com"。

最新更新