Skip to content

Instantly share code, notes, and snippets.

@ginkouno
Created November 27, 2016 10:58
Show Gist options
  • Save ginkouno/bece04d99d4fad7875dfc403fc907c43 to your computer and use it in GitHub Desktop.
Save ginkouno/bece04d99d4fad7875dfc403fc907c43 to your computer and use it in GitHub Desktop.
Google API周り
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