问题
The following snippet of code print events for a calendar id, all the calendar configured and try to set a watch notification on a calendar.
Everything works but the the watch event method. I'm getting this error: apis/core/http_command.rb:212:in `check_status': Unauthorized (Google::Apis::AuthorizationError)
thi seems strange since the calendars and events retrieve is working fine.
service = Google::Apis::CalendarV3::CalendarService.new
service.client_options.application_name = APPLICATION_NAME
service.authorization = authorize
# Fetch the next 10 events for the user
calendar_id = 'us7i4kt2to4mpb0b5et1f9f4co@group.calendar.google.com'
response = service.list_events(calendar_id,
max_results: 10,
single_events: true,
order_by: 'startTime',
time_min: Time.now.iso8601)
puts "Upcoming events:"
puts "No upcoming events found" if response.items.empty?
response.items.each do |event|
start = event.start.date || event.start.date_time
puts "- #{event.summary} (#{start})"
end
@calendar_list = service.list_calendar_lists
@calendar_list.items.each do |calendar|
puts " #{calendar.summary} => #{calendar.id}"
end
channel = Google::Apis::CalendarV3::Channel.new(address: 'https://66724be7.ngrok.io', id: 100, type: "web_hook")
puts "Channel created "
webhook = service.watch_event('us7i4kt2to4mpb0b5et1f9f4co@group.calendar.google.com', channel, single_events: true, time_min: Time.now.iso8601)
I'm getting this error: apis/core/http_command.rb:212:in `check_status': Unauthorized (Google::Apis::AuthorizationError)
can't find anything related on the web
来源:https://stackoverflow.com/questions/45314274/ruby-google-calendar-integration-watch-event-push-notification