Comments (3)
Any chance you could share how you go 2LO working? I've been struggling for a couple of days now with no luck. I've only been able to locate a few examples of people claiming they got it to work and those were either outdates, incomplete, or some combination of the two.
from google-api-ruby-client.
Mainly by checking the ruby source code and examining the older java client as described here, and logging the actual requests. I only checked Calendar v3 so I'm not sure about the other apis. At least for Calendar the xoauth_requestor_id
parameter is needed, Calendar API's documentation also makes mention of the API key for domain-wide delegation 2LO, but I realized it is not needed in my specific example:
Working example of accessing Calendar API v3 using OAuth1 in Ruby
# Initialize the client
require 'debugger'
require 'net-http-spy'
require 'google/api_client'
KEY = 'omitted'
SECRET = 'omitted'
API_KEY = "omitted"
client = Google::APIClient.new(
:key => API_KEY,
:authorization => :two_legged_oauth
)
# Block 4: Using 2LO (two_legged_oauth) + API key to access Calendar API
client.authorization.client_credential_key = KEY
client.authorization.client_credential_secret = SECRET
cal = client.discovered_api('calendar','v3')
result = client.execute(
:api_method => cal.events.list,
:parameters => {
'calendarId' => 'primary',
:key => API_KEY,
:xoauth_requestor_id => "[email protected]"
},
)
puts result.data.to_json
- Output:
16:09:25 prusswan@prusswan-mint dropmyemail (googleapps-integration)$ bundle exec ruby lib/dropmyemail/google_api_test.rb
I, [2013-06-10T16:10:49.741938 #22077] INFO -- : CONNECT: ["www.googleapis.com", 443]
I, [2013-06-10T16:10:49.748663 #22077] INFO -- : GET /discovery/v1/apis/calendar/v3/rest?key=AIzaSyCDQmNRkB2iwFU62ySo77fGMwl98EdLuAc
I, [2013-06-10T16:10:49.847158 #22077] INFO -- : PARAMS {}
I, [2013-06-10T16:10:49.847452 #22077] INFO -- : BODY: Net::HTTPOK
I, [2013-06-10T16:10:49.950445 #22077] INFO -- : CONNECT: ["www.googleapis.com", 443]
I, [2013-06-10T16:10:49.957003 #22077] INFO -- : GET /calendar/v3/calendars/primary/events?key=**omitted**&xoauth_requestor_id=support%40dropmyemail.mygbiz.com
I, [2013-06-10T16:10:50.453468 #22077] INFO -- : PARAMS {}
I, [2013-06-10T16:10:50.453918 #22077] INFO -- : BODY: Net::HTTPOK
{"kind":"calendar#events","etag":"\"3HZc1wy_mzFFhn5FKK0rPMjgApI/u9LbHHebzwV8OsntwpnGp1zzwqU\"","summary":"[email protected]","updated":"2013-06-06T08:41:23.420Z","timeZone":"Asia/Singapore","accessRole":"owner","defaultReminders":[{"method":"popup","minutes":10}],"items":[{"kind":"calendar#event","etag":"\"3HZc1wy_mzFFhn5FKK0rPMjgApI/MTM3MDUwNzA3MzM1NjAwMA\"","id":"r1j800h0n32qjjmimfg999aks4","status":"confirmed","htmlLink":"https://www.google.com/calendar/event?eid=cjFqODAwaDBuMzJxamptaW1mZzk5OWFrczQgc3VwcG9ydEBkcm9wbXllbWFpbC5teWdiaXouY29t","created":"2013-06-06T08:24:33.000Z","updated":"2013-06-06T08:24:33.356Z","summary":"Rubber Duck Day","description":"the day when yellow ducks will be liberated all over the country","location":"Tiongland","colorId":"5","creator":{"email":"[email protected]","displayName":"DME Support","self":true},"organizer":{"email":"[email protected]","displayName":"DME Support","self":true},"start":{"date":"2013-06-04"},"end":{"date":"2013-06-05"},"transparency":"transparent","iCalUID":"[email protected]","sequence":0,"reminders":{"useDefault":true}}]}
from google-api-ruby-client.
Thank you so much! This worked perfectly. After a couple days of trying and failing to get the authentication bits working, it's great to have a solution and be able to move forward with actually writing code to deal with calendar events.
from google-api-ruby-client.
Related Issues (20)
- NoMethodError: undefined method `discovered_api' for nil:NilClass HOT 1
- list_generatedapks issus
- `forbidden` exception when calling `commit_edit` HOT 1
- Need to support dataset.list and jobs.list API new field feature
- Vertex API (gemini-pro model) undefined method `has_key?' for ...
- add hook for http requests
- Google::Apis::Core::BaseService#root_url documented as an Addressable::URI, now treated as String HOT 3
- uninitialized constant Google::Apis::Core::DownloadCommand::Pathname HOT 2
- Adsense generate_account_report_csv returns nil due to content_type
- Support for Method: presentations.pages.getThumbnail in Slides HOT 2
- 404 not found HOT 1
- Insert table request is not able to copy already created table and paste it in another doc
- Add `Errno::ECONNRESET` to retriable network errors HOT 3
- Causing many GRPC requests per calling discovery engine search api once HOT 1
- No way to set `SSL_OP_IGNORE_UNEXPECTED_EOF` for ::HTTPClient, but Google services don't send `close_notify` HOT 1
- Warning: a recent release failed
- Constrain rexml version (or remove dep?) HOT 2
- `Google::Apis::AdminDirectoryV1::DirectoryService#insert_member` seems to ignore group’s `whoCanJoin` setting HOT 1
- Document for Google::Apis::GroupssettingsV1::Groups#who_can_join is not correct HOT 1
- Missing autoPricingMinPrice property in Google Merchant Product HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-api-ruby-client.