以下代码片段打印日历ID的事件,配置了所有日历,并尝试在日历上设置观看通知。
一切都有效,但是监视事件方法。我收到此错误:apis / core / http_command.rb:212:在`check_status':未经授权(Google :: Apis :: AuthorizationError)
由于日历和事件检索工作正常,这似乎很奇怪。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)
我收到此错误:apis / core / http_command.rb:212:在`check_status':未经授权(Google :: Apis :: AuthorizationError)
无法在网络上找到任何相关内容