-
Notifications
You must be signed in to change notification settings - Fork 4
Use Service Account
Takahiro Ooishi edited this page Aug 12, 2024
·
2 revisions
https://github.com/taka0125/google_spreadsheet_fetcher/tree/main/samples/service_account
::GoogleSpreadsheetFetcher::Authorizer::ServiceAccount
にこのファイルの内容を渡す
sheet_key = 'example_sheet_id'
GoogleSpreadsheetFetcher.configure do |config|
credential = Pathname.new('path_to_service_account_credential_file.json').read
config.authorizer = ::GoogleSpreadsheetFetcher::Authorizer::ServiceAccount.new(credential)
config.user_id = 'sample'
end
sheet_key = 'example_sheet_id'
fetcher = GoogleSpreadsheetFetcher::Fetcher.new(sheet_key, GoogleSpreadsheetFetcher.config.user_id)
pp fetcher.fetch_all_rows_by!(index: 0)