Skip to content

Instantly share code, notes, and snippets.

@dev-jonghoonpark
Created August 1, 2023 17:14
Show Gist options
  • Save dev-jonghoonpark/51d88bdc9b5643a32990b7f1d05d04da to your computer and use it in GitHub Desktop.
Save dev-jonghoonpark/51d88bdc9b5643a32990b7f1d05d04da to your computer and use it in GitHub Desktop.
서버에서 google sheet api 사용하기 (with python)
from __future__ import print_function
from google.oauth2 import service_account
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
# If modifying these scopes, delete the file token.json.
SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
# The ID and range of a sample spreadsheet.
SPREADSHEET_ID = 'YOUR_SPREADSHEET_ID'
RANGE_NAME = 'YOUR_RANGE_NAME'
def main():
try:
credentials = service_account.Credentials.from_service_account_file('credentials.json', scopes = SCOPES)
service = build('sheets', 'v4', credentials=credentials)
# Call the Sheets API
except HttpError as err:
print(err)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment