RailsでGoogleスプレッドシートを扱うための設定


configフォルダに「config.json」を作成し、
JSON形式で

{
  "client_id": "指定ID",
  "client_secret": "指定クライアントシークレット",
  "scope": [
    "https://www.googleapis.com/auth/drive",
    "https://spreadsheets.google.com/feeds/"
  ],
  "refresh_token": "リフレッシュトークン"
}


を作成。

あとは、

session = GoogleDrive::Session.from_config('config.json')
sheets = session.spreadsheet_by_key("スプレッドシートキー").worksheets[0]


を差し込んで完了です。