Ruby 透過 Google API 串接 Excel (SpreadSheet)
2024-01-17
文章目錄
本文最後更新日期 2024/1/17。
# Gemfile gem 'googleauth' gem 'google-apis-sheets_v4'client = Google::Apis::SheetsV4::SheetsService.new cred_file = '/tmp/secret.json' authorizer = Google::Auth::ServiceAccountCredentials.make_creds(json_key_io: File.open(cred_file), scope: [Google::Apis::SheetsV4::AUTH_SPREADSHEETS]) client.authorization = authorizer
- cred_file 為準備工作所下載的憑證檔案
- scope 可參考官方資料 (搜尋 "AUTH_")