Git Product home page Git Product logo

google_calendar's Introduction

Google Calendar

A fast lightweight and minimalist wrapper around the Google Calendar api.

<img src=“https://badge.fury.io/rb/google_calendar.svg” alt=“Gem Version” /> <img src=“https://travis-ci.org/northworld/google_calendar.png?branch=master” alt=“Build Status” /> <img src=“https://codeclimate.com/github/northworld/google_calendar/badges/gpa.svg” /> <img src=“https://codeclimate.com/github/northworld/google_calendar/badges/coverage.svg” />

Install

[sudo] gem install 'google_calendar'

Setup

Important Changes: Google no longer supports the ‘urn:ietf:wg:oauth:2.0:oob’ out-of-band OAuth method. You must setup your OAuth Credentials with a publically accessible URL where you can grab your code from the URL paramaters after approving the OAuth request. If your product is a Web Application, you can automate this set up by pointing the redirect_url to the appropriate method of your application.

Obtain a Client ID and Secret

  1. Go to the Google Developers Console.

  2. Select a project, or create a new one (at the top of the page).

  3. In the sidebar on the left, select Library.

  4. Type in ‘Google Calendar’ in the search box and click on ‘Google Calendar API’ in the results.

  5. Click on the ‘Enable’ link at the top of the page.

  6. In the sidebar on the left, select Credentials.

  7. If you haven’t done so already, create your ‘OAuth client ID’ by clicking ‘Create Credentials -> OAuth client ID’. Choose Web Application as the type.

  8. You must also provide an “Authorized redirect URIs” which is a publically reachable URL where google will redirect to after the OAuth approval. Google will append the paramater ‘code=<your auth code>’ to this URL during redirection which will include the necessary code to authenticate the usage of this application.

  9. Take note of the Client ID and Client Secret as you’ll need to add it to your code later.

  10. In the sidebar on the left, select “OAuth consent screen”. You must setup your Application Name, and add “Test users” if this is for personal use (i.e. you are setting up links to at limited set of known users’ calendars), or “Publish” your app if this is for public use.

Find your calendar ID

  1. Visit Google Calendar in your web browser.

  2. In the calendar list on the left, click the three vertical dots next to the appropriate calendar, then select ‘Settings and sharing’.

  3. From the left toolbar, choose ‘Integrate Calendar’.

  4. In the Integrate Calendar section, locate the Calendar ID at the top of the section.

  5. Copy the Calendar ID.

Usage (readme_code.rb)

require 'rubygems'
require 'google_calendar'

# Create an instance of the calendar.
cal = Google::Calendar.new(:client_id     => YOUR_CLIENT_ID,
                           :client_secret => YOUR_SECRET,
                           :calendar      => YOUR_CALENDAR_ID,
                           :redirect_url  => YOUR_REDIRECT_URL # This must match a url you permitted in your OAuth setting
                           )

puts "Do you already have a refresh token? (y/n)"
has_token = $stdin.gets.chomp

if has_token.downcase != 'y'

  # A user needs to approve access in order to work with their calendars.
  puts "Visit the following web page in your browser and approve access."
  puts cal.authorize_url
  puts "\nCopy the code out of the paramters after Google redirects you to your provided redirect_url"

  # Pass the ONE TIME USE access code here to login and get a refresh token that you can use for access from now on.
  refresh_token = cal.login_with_auth_code( $stdin.gets.chomp )

  puts "\nMake sure you SAVE YOUR REFRESH TOKEN so you don't have to prompt the user to approve access again."
  puts "your refresh token is:\n\t#{refresh_token}\n"
  puts "Press return to continue"
  $stdin.gets.chomp

else

  puts "Enter your refresh token"
  refresh_token = $stdin.gets.chomp
  cal.login_with_refresh_token(refresh_token)

  # Note: You can also pass your refresh_token to the constructor and it will login at that time.

end

event = cal.create_event do |e|
  e.title = 'A Cool Event'
  e.start_time = Time.now
  e.end_time = Time.now + (60 * 60) # seconds * min
end

puts event

event = cal.find_or_create_event_by_id(event.id) do |e|
  e.title = 'An Updated Cool Event'
  e.end_time = Time.now + (60 * 60 * 2) # seconds * min * hours
end

puts event

# All events
puts cal.events

# Query events
puts cal.find_events('your search string')

This sample code is located in readme_code.rb in the root folder.

Ruby Support

The current google_calendar gem supports Ruby 2.1 and higher – because of the json gem dependency. We maintain support for Ruby 1.8.7, 1.9.3 and 2.0 on different branches.

Notes

  • This is not a complete implementation of the calendar api, it just includes the features we needed to support our internal calendar integration. Feel free to add additional features and we will happily integrate them.

  • Did you get an SSL exception? If so take a look at this: gist.github.com/fnichol/867550

Contributing to google_calendar

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Running Tests

The first time you run rake test Rake will copy over .env.test to .env for use by Dotenv. You can also use .env.default as your own starting point, just remember to copy it over to .env before running tests.

You can modify .env with your own credentials and don’t worry about accidentally committing to the repo as .env is in the .gitignore.

Copyright © 2010-2022 Northworld, LLC. See LICENSE.txt for further details.

google_calendar's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google_calendar's Issues

Attachments

Hi Northworld team, greatly appreciated your google_calendar gem 👍

Is there any method to CRUD the Google Drive attachments that can be added to a Google Calendar events accounting to the Google Calendar API?

Many thanks,

Arnold

1st example code throws an error

when i run the example code from the documentation i get the following behviour (see base), any idea where i should look to resolve this? it is generated by both the "puts cal.events" and "puts cal.find_events('swimming')' lines.

A Cool Event (r7bi1ke7tplau3q4jg4d11fetc)
        2012-10-17T17:51:27Z
        2012-10-17T18:51:27Z


An Updated Cool Event (r7bi1ke7tplau3q4jg4d11fetc)
        2012-10-17T11:51:27.000-06:00
        2012-10-17T19:51:28Z


/home/jlovick/.rvm/gems/ruby-1.9.3-p194/gems/google_calendar-0.2.2/lib/google/event.rb:156:in `new_from_xml': undefined method `[]' for nil:NilClass (NoMethodError)
        from /home/jlovick/.rvm/gems/ruby-1.9.3-p194/gems/google_calendar-0.2.2/lib/google/event.rb:98:in `block in build_from_google_feed'
        from /home/jlovick/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/lib/nokogiri/xml/node_set.rb:239:in `block in each'
        from /home/jlovick/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/lib/nokogiri/xml/node_set.rb:238:in `upto'
        from /home/jlovick/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/lib/nokogiri/xml/node_set.rb:238:in `each'
        from /home/jlovick/.rvm/gems/ruby-1.9.3-p194/gems/google_calendar-0.2.2/lib/google/event.rb:98:in `collect'
        from /home/jlovick/.rvm/gems/ruby-1.9.3-p194/gems/google_calendar-0.2.2/lib/google/event.rb:98:in `build_from_google_feed'
        from /home/jlovick/.rvm/gems/ruby-1.9.3-p194/gems/google_calendar-0.2.2/lib/google/calendar.rb:171:in `event_lookup'
        from /home/jlovick/.rvm/gems/ruby-1.9.3-p194/gems/google_calendar-0.2.2/lib/google/calendar.rb:68:in `find_events'
        from google_calendar.ruby:27:in `<main>'

Newlines in description

I was trying to put newlines in the description. Failed with a parse error.

Per http://stackoverflow.com/questions/7830582/newline-for-google-calendar-api it turns out this needs to be json escaped. Tried using solution on http://stackoverflow.com/questions/6783988/encode-a-ruby-string-to-a-json-string only to find that something objected to the leading and trailing quote.

      description_json = description.to_json
      description_json.gsub!(/\A"|"\Z/, '')

      event = @cal.create_event do |e|
        e.title = title
        e.start_time = time_object_start
        e.end_time = time_object_end
        e.description = description_json
      end

Is my ugly workaround.

Creating new calendars

Hi,
how difficult it'll be to allow creating new calendars and not passing calendar_id?
What are the cases I should handle to allow that? and not passing calendar_id to Google::Calendar.new

Any technical reason its not already supported?

Recurrence rule error

Hi @szich,

I had to do this small change (rafaeliga@c5949c2) in the recurrence rule to fix the error attached.

google_calendar_error

Im not sure if the calendar data that Im trying to parse is somehow wrong and my fix does not make any sense.

Thanks,

SSL error on a Mac?

Hi,
I get the SSL error - is this normal on a Mac? It makes me think something is wrong with my install.

http://gist.github.com/fnichol/867550 seems to be targeted at Windows.

Thanks,
Martin.

Copy the code that Google returned and paste it here:
(omitted)
/opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:920:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Faraday::SSLError)
    from /opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:920:in `block in connect'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:920:in `connect'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:852:in `start'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:1369:in `request'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:82:in `perform_request'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:40:in `block in call'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:87:in `with_net_http_connection'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:32:in `call'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/request/url_encoded.rb:15:in `call'
    from /Volumes/Storage/martincleaver/.chefdk/gem/ruby/2.1.0/gems/signet-0.6.1/lib/signet/oauth_2/client.rb:957:in `fetch_access_token'
    from /Volumes/Storage/martincleaver/.chefdk/gem/ruby/2.1.0/gems/signet-0.6.1/lib/signet/oauth_2/client.rb:983:in `fetch_access_token!'
    from /Volumes/Storage/martincleaver/.chefdk/gem/ruby/2.1.0/gems/google_calendar-0.5/lib/google/connection.rb:133:in `get_new_access_token'
    from /Volumes/Storage/martincleaver/.chefdk/gem/ruby/2.1.0/gems/google_calendar-0.5/lib/google/connection.rb:94:in `login_with_auth_code'
    from /Volumes/Storage/martincleaver/.chefdk/gem/ruby/2.1.0/gems/google_calendar-0.5/lib/google/calendar.rb:73:in `login_with_auth_code'
    from gc.rb:24:in `<main>'

All Day Event for Specific Calendar

Right now, I have ...
puts cal.events
... working for showing a list of the events on my calendar.

How do I show the details for all-day events for a particular calendar? - Can you show an example of how to do that?

Google::HTTPAuthorizationFailed

I can use my oauth creds, get refresh tokens, and make requests to the calendar api while running an application locally. When I try to run this on a server I consistently get HTTPAuthorizationFailed. I have tried using different oauth creds, calendar ids. All credentials seem correct on the remote server. Oauth allowed urls seem correct also, unless this library appears from a different origin than other requests from the server.

I'm pretty much out of ideas aside from pulling the library apart to get a clearer picture of what requests are being made to google.

Any ideas?

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "ansi":
  In Gemfile:
    minitest-reporters (~> 1.2) was resolved to 1.3.5, which depends on
      ansi

Could not find gem 'ansi', which is required by gem 'minitest-reporters (~> 1.2)', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Issue with events()

I initialize the calendar:

g = Google::Calendar.new(username:'[email protected]', password:'foofoo', calendar:'foocal')

then:

g.events

and then I get:

NoMethodError: undefined method `[]' for nil:NilClass
from /Users/mario/.rvm/gems/ruby-1.9.3-p327-fast/gems/google_calendar-0.2.9/lib/google/event.rb:172:in `new_from_xml'
from /Users/mario/.rvm/gems/ruby-1.9.3-p327-fast/gems/google_calendar-0.2.9/lib/google/event.rb:112:in `block in build_from_google_feed'
from /Users/mario/.rvm/gems/ruby-1.9.3-p327-fast/gems/nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:239:in `block in each'
from /Users/mario/.rvm/gems/ruby-1.9.3-p327-fast/gems/nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:238:in `upto'
from /Users/mario/.rvm/gems/ruby-1.9.3-p327-fast/gems/nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:238:in `each'
from /Users/mario/.rvm/gems/ruby-1.9.3-p327-fast/gems/google_calendar-0.2.9/lib/google/event.rb:112:in `collect'
from /Users/mario/.rvm/gems/ruby-1.9.3-p327-fast/gems/google_calendar-0.2.9/lib/google/event.rb:112:in `build_from_google_feed'
from /Users/mario/.rvm/gems/ruby-1.9.3-p327-fast/gems/google_calendar-0.2.9/lib/google/calendar.rb:174:in `event_lookup'
from /Users/mario/.rvm/gems/ruby-1.9.3-p327-fast/gems/google_calendar-0.2.9/lib/google/calendar.rb:54:in `events'
from (irb):48
from /Users/mario/.rvm/gems/ruby-1.9.3-p327-fast/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
from /Users/mario/.rvm/gems/ruby-1.9.3-p327-fast/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /Users/mario/.rvm/gems/ruby-1.9.3-p327-fast/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

#all_day?

The all_day method doesn't work as expected. First, any 24 hour event is considered as all day, which is wrong. By my expectation it should only consider all day events as events that were marked as AD in google UI. Second, you can have multiple-day All Day event, not only single day.

Accessing calendar from back-end

Hello! I wonder how I could access the calendar from back-end if I authorised already my application and I have a Google token?

Can't login from remote computer

I'm receiving Error=BadAuthentication (Google::HTTPAuthorizationFailed) when I tried to login from c9.io, the error is also returning an url and also Info=WebLoginRequired, the url is valid and I can use it to login, but it won't help with anything.

I know it's not a bug with the google_calendar gem, so you guys can mark it with a won't fix, but I wanted to let you guys aware about this google policy.

Multi-user use case

I'm trying to use this to either have a different calendar for each user (requires creation of calendar support as well as calendar id reading support) OR have each users profile create events on a shared calendar. With the second option, I am guessing the user should never need to connect their google account, as all auth can be done through a service account's refresh token.

I like the idea of using the users auth to login but I don't think that would fit with using the shared calendar approach.

What's the recommended approach?

Ruby gem have old source codes

Hi!

I get old version of goole_calendar when I install it by gem install.

For example self.new_from_feed() function in events.rb.

Can you update gem source to last?

Accessing a calendar's time zone

Does the wrapper currently persist the timezone of the calendar? I wasnt able to find it anywhere.

From the api documentation:

{
"kind": "calendar#calendar",
"etag": etag,
"id": string,
"summary": string,
"description": string,
"location": string,
"timeZone": string
}

find_events_in_range broken?

My code that used to work:

cal.find_events_in_range(Time.now, Time.now + 60)

It now produces this error:

/Users/alexforey/.rvm/gems/ruby-2.1.5/gems/google_calendar-0.4.1/lib/google/connection.rb:139:in `check_for_errors': { (Google::HTTPRequestFailed)
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "badRequest",
    "message": "Bad Request"
   }
  ],
  "code": 400,
  "message": "Bad Request"
 }
}

Whereas just doing this works fine and returns a list of all of the events:

cal.events

Am I doing something wrong? The message and circumstances make me think that there's something wrong with encode_time or the way that's passed onto the query string.

All retrieved events are marked as transparent

It seems that the Google Calendar API only mentions in event JSON when the event is actually transparent. If the event is opaque, it is not part of the event JSON.
However, then for the opaque events Event.new_from_feed passes nil as value to transparency= (via initialize) which will then default to it setting @transparency to "transparent" which is the wrong outcome.
As a result, all retrieved events are marked as transparent.

A solution would be to have initialize do:

self.transparency = params[:transparency] || "opaque"

Another solution would be to have new_from_feed not parse it as part of the standard list of params but have an explicit line:

params[:transparency] = e['transparency'] || "opaque"

I could not find in the docs whether it transparancy actually should default to "opaque" (the UI does). If this case, maybe event's transparency= could be adapted to use:

if val.nil? || val == false || val.to_s.downcase == 'opaque'

Zone conversion bug

I've run into a bug whereby my results from a find_future_events call gets the right @raw data in response, but the start time conversion to an attribute ignores or does something weird with the zone:

@raw=
    ...
    "start"=>
     {"dateTime"=>"2017-04-24T10:00:00-04:00", "timeZone"=>"America/New_York"},
    ...
@start_time=2017-04-24 14:00:00 UTC

I'm happy to submit a pull request to fix it but I thought I'd mention it here first in case it's something I'm missing.

client_secret

What's the client secret? In the Google Developer console, under APIs & auth / Credentials, in the OAuth section, I only have "client id", "email address" and "certificate fingerprints". I've also been given a .p12 file. But your gem requires both client id and client secret, and I've no idea where to find the secret.

ssl error

Hi I had written a small app last year to help me update my working shifts in google calendar using this gem.

It seems something changed in the oath2 verification process. So I updated Google_calendar and registered my app.

When I try to connect using the provided code in the readme_code.rb

I get the following error after I provide the verification code given by google.
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Faraday::SSLError)

it's probably my crappy coding skills, but i'm at a loss. using ruby 1.9.3 and/or ruby 2

Attributes not writable

Hi,

Thanks for this gem, very nice work.
I juste notices that some attributes are said being writable on https://developers.google.com/google-apps/calendar/v3/reference/events/insert#examples like the "id" but only readable in your library.

attr_reader :id, :raw, :html_link, :status

I got a:

/data/calendar.rb:51:in `block in <main>': undefined method `id=' for #<Google::Event:0x000000020a2dd0> (NoMethodError)
  from /usr/local/rvm/gems/ruby-2.1.5/gems/google_calendar-0.4.4/lib/google/calendar.rb:263:in `setup_event'
  from /usr/local/rvm/gems/ruby-2.1.5/gems/google_calendar-0.4.4/lib/google/calendar.rb:180:in `create_event'
  from /data/calendar.rb:45:in `<main>'

Is there a particular reason?

Thank you.

find_event_by_id() find deleted events?

I had install last version (master branch) and having problems when I am looking for event by id which was deleted from GUI google calendar. I get event with all attributes, like it exists.
In older version, I get nil event, if it not exists.
Is there any way, how to check if event exist on googleCalendar.
Tnx!

Best regards.

Сonfirmation of the event of attendees

How I can send email with event notification to all my attendees? And what I must check, if I don't want attendee to see each other in the event.
Thank you.

"all_day?" exploding because @start_time was a Time instead of String

We got an exception from "all_day?" because @start_time was a Time instead of a String.

I think this can be reproduced with something like

event = some_all_day_event
event.start_time  # Now @start_time is assigned a Time due to how that reader works.
event.all_day?  # Now it explodes

Missing rest of CRUD operations for calendar

I noticed that this library lacks methods to handle calendar resource. It provides create, but nothing else. I added rudimentary update, get, and delete methods for calendar resource.

Currently the implementation lacks tests. I also think the library needs error handling for authorization (access to particular calendar resource or event resource), since authorization is critical for update and delete operations.

Is Version 0.5 gem out of sync with github?

My Ruby runtime and IDE say there is no method =find_events_by_extended_properties_in_range=

On inspection I see:

google_calendar 2015-10-04 10-48-11

 gem which google_calendar
/Volumes/Storage/martincleaver/.chefdk/gem/ruby/2.1.0/gems/google_calendar-0.5/lib/google_calendar.rb

Is the gem source out of sync?

Thanks,
Martin.

Example code didn't work on Windows?

I trying use your example code on Windows. I installed all gems to application but, when i try generate refresh token it throw me

C:/Ruby200/lib/ruby/2.0.0/net/http.rb:918:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Faraday::SSLError)
    from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'
    from C:/Ruby200/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
    from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:918:in `connect'
    from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
    from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:851:in `start'
    from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1367:in `request'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:80:in `perform_request'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:39:in `call'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/faraday-0.9.0/lib/faraday/request/url_encoded.rb:15:in `call'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/signet-0.5.1/lib/signet/oauth_2/client.rb:933:in `fetch_access_token'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/signet-0.5.1/lib/signet/oauth_2/client.rb:956:in `fetch_access_token!'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/google_calendar-0.4.2/lib/google/connection.rb:128:in `get_new_access_token'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/google_calendar-0.4.2/lib/google/connection.rb:84:in `login_with_auth_code'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/google_calendar-0.4.2/lib/google/calendar.rb:73:in `login_with_auth_code'
    from ./a.rb:22:in `<main>'"

Some idea what is wrong?

Bad authentication

I am trying to authenticate per your instructions for V3 of Google Calendar's API and I am getting bad authentication. I set up an application and choose "web application" and then copied and pasted the client_id, client_secret and calendar_id for authentication. Has anyone else experienced this?

parseError

I am getting the following error when trying to create an event like this:

    calendar.create_event do |e|
      e.title = "Initial consultation with #{params[:name]}"
      e.location = "Skype handle - #{params[:skype]}"
      e.description = "#{params[:name]} requested an appointment: 
      \nPhone Number: #{params[:phone_number]}
      Email: #{params[:email]}  
      Notes: #{params[:notes]}"
      e.start_time = appointment_time
      e.end_time = appointment_time + (30 * 60)
    end 
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "parseError",
    "message": "Parse Error"
   }
  ],
  "code": 400,
  "message": "Parse Error"
 }
}

I don't get the error when I omit the description and location fields. Did the API change the way they parse strings?

Signet::AuthorizationError -- invalid_user

I'm in the deep end here.

I set this:
cal = Google::Calendar.new( client_id: ##, client_secret: ##, calendar: ##, redirect_url: "urn:ietf:wg:oauth:2.0:oob")

Then I call this:
cal.login_with_refresh_token(ENV['GCAL_REFRESH_TOKEN'])

And I get Google::HTTPAuthorizationFailed

So, like a good little novice, I start tracking the code. I find the Connection#initialize block and see the Signet::OAuth2::Client.new()

I replicate that in the console:
client = Signet::OAuth2::Client.new( client_id: '##.apps.googleusercontent.com', client_secret: '##', redirect_uri: "urn:ietf:wg:oauth:2.0:oob", refresh_token: '##', authorization_uri: "https://accounts.google.com/o/oauth2/auth", token_credential_uri: "https://accounts.google.com/o/oauth2/token", scope: "https://www.googleapis.com/auth/calendar", grant_type: "refresh_token")

Then I try client.fetch_access_token! and get:
Signet::AuthorizationError: Authorization failed. Server message: { "error" : "invalid_user" }

I see my client object does have client.username and client.password, but not where this app would set those fields. Am I missing something?

calendars.clear always returns "Cannot clear primary calendar."

client.execute!(:api_method => calendar_api.calendars.clear,
:parameters => { :calendarId => id }
)

Always returns:

/opt/ruby2.2.3/lib/ruby/gems/2.2.0/gems/google-api-client-0.8.6/lib/google/api_client.rb:662:in `block (2 levels) in execute!': Cannot clear primary calendar. (Google::APIClient::ClientError)

Despite 'id' being a secondary calendar.

Calendar event title seems to throw errors if it contains a &

for the event title "Early Dismissal for Gr 9 & 10"

i am trying to create a new event,

replacing the & with a "and" fixes things, should the title string be escaped somehow?

error given is ........
The entity name must immediately follow the '&' in the entity reference.
/home/jlovick/.rvm/gems/ruby-1.9.2-head/gems/google_calendar-0.2.2/lib/google/connection.rb:86:in send' /home/jlovick/.rvm/gems/ruby-1.9.2-head/gems/google_calendar-0.2.2/lib/google/calendar.rb:131:insave_event'
/home/jlovick/.rvm/gems/ruby-1.9.2-head/gems/google_calendar-0.2.2/lib/google/event.rb:135:in save' /home/jlovick/.rvm/gems/ruby-1.9.2-head/gems/google_calendar-0.2.2/lib/google/calendar.rb:214:insetup_event'
/home/jlovick/.rvm/gems/ruby-1.9.2-head/gems/google_calendar-0.2.2/lib/google/calendar.rb:113:in `create_event'

source code snippet is...
to_calendar.create_event do |e|
e.title = from_event.title.strip
e.content = from_event.content.strip + "\n" + "{ id : "+from_event.id +
"\n source_calendar : " + (src_calendar) +
" } \n"
e.where = from_event.where
e.start_time = from_event.start_time
e.end_time = from_event.end_time
end

service account or web app

hi, when i try to create new client id and select service account it gives me these
Client ID
Email address
Public key fingerprints
when i select web app it asks for Authorized JavaScript origins and Authorized redirect URIs what should i choose and if it is web app what should i type these fields?

Event.all_day

The new implementation of all_day? assumes @start_time is a string object, when it can in fact be a Time object.

I am using the event and getting the following error message when calling all_day?

_parse': undefined method `gsub!' for 2014-03-02 09:35:30 UTC:Time (NoMethodError)

This is occurring because @start_time is an object of type time and doesn't respond to gsub.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.