import httplib2 import googleapiclient.discovery from oauth2client.service_account import ServiceAccountCredentials from config import CREDENTIALS_FILE, SPREADSHEET_ID def get_google_service(): credentials = ServiceAccountCredentials.from_json_keyfile_name( CREDENTIALS_FILE, [ "https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/drive", ], ) http = credentials.authorize(httplib2.Http()) return googleapiclient.discovery.build( "sheets", "v4", http=http, cache_discovery=False )