Created
November 27, 2016 10:58
-
-
Save ginkouno/bece04d99d4fad7875dfc403fc907c43 to your computer and use it in GitHub Desktop.
Google API周り
This file contains hidden or 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/apis/sheets_v4' | |
require 'google-drive-ruby' | |
client_id = 'YOUR_CLIENT_ID' | |
client_secret = 'YOUR_CLIENT_SECRET' | |
refresh_token = 'YOUR_REFRESH_TOKEN' | |
credentials = Google::Auth::UserRefreshCredentials.new( | |
client_id: client_id, | |
client_secret: client_secret, | |
scope: [ | |
"https://www.googleapis.com/auth/drive" | |
], | |
redirect_uri: "httsp://localhost/callback") | |
credentials.refresh_token = refresh_token | |
credentials.fetch_access_token! | |
session = GoogleDrive.login_with_oauth(credentials.access_token) | |
session.upload_from_file('sample.csv', 'sample.csv', convert: false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment