Rails + Google Calendar API Events Not Created

Rails + Google Calendar API events not created

I faced with same problem. Needed give write rules to "client_email" for calendar.

You use organization calendar. Thats why only organization admin can do it.

Add Event to Calendar of another user using Google::Api::V3

The solution to my problem was adding an attendee to the params of my new event. I specified the email of the host in this case and the event was added to both the cleaners calendar and the host's calender. Here's my new_event method that inserts the event into both calendars

def new_event(start, endd, cleaner, host)
client = Signet::OAuth2::Client.new(client_options)
client.update!(session[:authorization])
service = Google::Apis::CalendarV3::CalendarService.new
service.authorization = client
calendar = service.get_calendar(:primary)
today = Date.today
event = Google::Apis::CalendarV3::Event.new({
start: Google::Apis::CalendarV3::EventDateTime.new(date: start),
end: Google::Apis::CalendarV3::EventDateTime.new(date: endd),
attendees: [{email: host.email}],
summary: "Cleaning Scheduled by #{cleaner}"
})
service.insert_event(calendar.id, event)
end

Google Calendar Api : How to send notification email to attendee when i add it to an event?

At calendar API, sendUpdates is used as the query parameter. So how about this modification?

From:

result = service.update_event(ENV['CALENDAR_ID'], event.id, event)

To:

result = service.update_event(ENV['CALENDAR_ID'], event.id, event, send_updates: 'all')

Reference:

  • update_event()
  • Events: update

If this was not the result you want, I apologize.

Google Calendar API insert event without auth Rails

I found solution. Needed use server-to-server auth.

Next page has this solution: Rails + Google Calendar API events not created



Related Topics



Leave a reply



Submit