How to interact with a CalDAV server from Ruby?
I ended up using the library at http://www.local-guru.net/blog/pages/rubycaldav
I had to adapt it work with SSL, and use the UUID library correctly, format the dates correctly and work with Full day events. Since I only needed to create and destroy Events that is all i updated. I plan to do more with in when i have time.
My updated code can be found here https://github.com/loosecannon93/ruby-caldav.
The problem I was having was supplying incorrectly formatted dates, and lack of UUIDs.
The caldavtest.rb
file on GitHub is what I used to work
An additional Complication i ran into was that Zimbra ( the server ) has 2 paths, one for ICS files that are readonly /home/user@host/Calender
and one for CalDAV /dav/user@host/Calendar
I hope that someone may find help with this solution.
However there is a substantial lack of cladav implementation for Ruby. There are ICS libraries that form objects, but there is only pure Net::HTTP to interact with a server. Local-guru's is the only ruby one I found that works both ways, but it is in need of some help with minor issues.
I fixed some of these but not project wide, I just had to get it working. But if someone would like to contribute I would love to help.
How to set up Google Calendar API using Ruby client for server to server applications
AUTHORIZATION SETUP FOR GOOGLE CALENDAR
Somewhat helpful link: https://developers.google.com/api-client-library/ruby/- Go to: https://console.developers.google.com/iam-admin/projects
- Click "+Create Project"
- Enter a "Project name" and "Project ID" and click "Create"
- Under "Library" select "Calendar API"
- Click ">Enable"
- Return to: https://console.developers.google.com/iam-admin/projects
- Click "Service Accounts"
- Click "Select a project"
- Choose your project and click "Open"
- Click "+Create Service Account"
- Enter a "Service account name" and choose a "Role" (I chose "editor")
- Check "Furnish a new private key"
- Click "Create"
Move this file to some place accessible by your application and rename it to "google_api.json" (or whatever you want as long as it matches the correct path below). Ensure that only the application can access this file (it contains a private key).
- Copy the "client_email" from the JSON file and go to the settings of the
Google Calendar that you want this application to access. - Click "Calendars"
- Choose the correct calendar
- Click "Change sharing settings" found under "Calendar Address:"
- Add the email you copied and select the proper permission
- Click "Save"
- Copy the "Calendar ID" to the right of "Calendar Address:"
- You can hardcode the calendar ID below or put it in YAML file or as an environmental variable.
# http://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/CalendarV3
require 'googleauth'
require 'google/apis/calendar_v3'
class MyApp::GoogleCalendar
def initialize
authorize
end
def service
@service
end
def events(reload=false)
# NOTE: This is just for demonstration purposes and not complete.
# If you have more than 2500 results, you'll need to get more than
# one set of results.
@events = nil if reload
@events ||= service.list_events(calendar_id, max_results: 2500).items
end
private
def calendar_id
@calendar_id ||= # The calendar ID you copied in step 20 above (or some reference to it).
end
def authorize
calendar = Google::Apis::CalendarV3::CalendarService.new
calendar.client_options.application_name = 'App Name' # This is optional
calendar.client_options.application_version = 'App Version' # This is optional
# An alternative to the following line is to set the ENV variable directly
# in the environment or use a gem that turns a YAML file into ENV variables
ENV['GOOGLE_APPLICATION_CREDENTIALS'] = "/path/to/your/google_api.json"
scopes = [Google::Apis::CalendarV3::AUTH_CALENDAR]
calendar.authorization = Google::Auth.get_application_default(scopes)
@service = calendar
end
end
So now you can call cal = MyApp::GoogleCalendar.new
and get the events with cal.events
. Or you can make calls directly with cal.service.some_method(some_args)
, rather than creating methods in this file. Google Calendar API server to server Rails
I found solution.
Use for it api v.0.8.2 and see next page:
Rails + Google Calendar API events not created
Interacting with Outlook appointments using rails
Outlook appointments are just e-mails with special header information. There's some information in this tutorial on the required parts. I sent a few meeting invites from my Outlook to my Gmail account and took a look at the raw headers there - you can figure most of the protocol out from that.
The iCalendar specs may help you, as well.
Related Topics
Gem Install Pg for Ruby on Rails
Timeout When Installing Ruby Gems
More Ruby Way of Doing Project Euler #2
Puzzled Over Palindromic Product Problem
How to Show Longer Traces in Rails Testcases
Why Do Ruby People Say They Don't Need Interfaces
Automatically Logging Exceptions in Ruby
How to Reverse a Linked List in Ruby
Using Elasticsearch to Filter Through Tags with Whitespace
Ruby: How to Convert an Array of Data to Hash and to JSON Format
How to Run Capybara-Webkit (I.E. Forked Webkit_Server) on Heroku Cedar
Gem Ransack Doesn't Return Any Results When Searched with Full Name
What Does Bundle Install -Without Production Do
Ruby - Generate All Two Letter Words
Running Capybara Without Rack Produces Errors When Using Url Parameters