Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google_oauth

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google_oauth

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

OAuth2 Google Data client library for Ruby

Install the gem

gem install google_oauth

Authorization

Before you begin you will need a client_id and client_secret for your application from Google. You can create one from the Google API Console - ensure you click on API Access and create an OAuth2 client ID.

With your Client ID credentials you can now initialize the client:

client = GoogleOAuth::Client.new(
  :client_id => 'YOUR_CLIENT_ID', 
  :client_secret => 'YOUR_CLIENT_SECRET', 
  :redirect => 'YOUR_REDIRECT_URI',
)

redirect_to client.authorization_url

At this point the client is redirected to the Google login page. If they authorize your application then Google will return to your redirect URL with a code parameter.

token = client.authorize(:code => params[:code])

You now have a valid token that you can store for future requests. You can initialize the client with this token if you already have it:

client = GoogleOAuth::Client.new(
  :client_id => 'YOUR_CLIENT_ID', 
  :client_secret => 'YOUR_CLIENT_SECRET', 
  :token => 'USER_TOKEN'
)

Working with Calendars

The Google Calendar API supports the jsonc format. Check out the Google Documentation to see what properties are available.

Here is an example that gets the users first calendar and loops over all the events:

calendar = client.own_calendars.items.first

client.events(calendar.eventFeedLink).items.each do |event|
  puts event.title
end

FAQs

Package last updated on 04 May 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc