Last active
August 29, 2015 14:25
-
-
Save alejandrobabio/f14ad6545e24d25eec02 to your computer and use it in GitHub Desktop.
Script for read google drive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'google_drive' | |
client = Google::APIClient.new(application_name: 'Google Drive Ruby test', application_version: '0.0.1') | |
key = Google::APIClient::KeyUtils.load_from_pkcs12( | |
'path to your p12 key file (all the path with file name)', | |
'your secret here given at download file it seems to be always the same: notasecret') | |
asserter = Google::APIClient::JWTAsserter.new( | |
'service account - email address - here', | |
['https://www.googleapis.com/auth/drive'], | |
key | |
) | |
client.authorization = asserter.authorize | |
session = GoogleDrive.login_with_oauth(client.authorization.access_token) | |
# access data | |
# all files shared with the 'email address' at asserter | |
session.files { |file| puts file } | |
# some spreadsheet | |
spreadsheet = session.spreadsheet_by_key('the alpha key at the link') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment