我是googleapiclient的新手。现在,我想出了代码,以使用certificate.json和token.pickle将数据从GSheet获取到S3。
scope = ['https://www.googleapis.com/auth/spreadsheets.readonly']
credentials = get_google_token(scope=scope,token_file=token_file,cred_file=cred_file)
service = build('sheets','v4',credentials=credentials,cache_discovery=False)
range_name = sheet_title + '!' + sheet_range_name
# Call the Sheets API
sheet = service.spreadsheets()
result = sheet.values().get(spreadsheetId=spreadsheetId,range=range_name
).execute()
当我尝试更新记录时(反之亦然),我无法授权Http,并且我不知道如何处理“使用Google API Client编写Google Sheet”。
scope = ['https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
credentials = get_google_token(scope=scope,cred_file=cred_file)
print(credentials)
service = build('sheets',credentials=credentials)
print(service)
values = {'values':[['Hello World',],]}
range_name = sheet_title + '!' + sheet_range_name
# Call the Sheets API to Update the Value
result = service.spreadsheets().values().update(spreadsheetId=spreadsheetId,range=sheet_range_name,valueInputOption='RAW',body=values).execute()