如何正确连接到Google Spreadsheets API?

问题描述 投票:1回答:1

我想用Python连接到Google Spreadsheets API。

所以我这样做:

import gspread
from oauth2client.service_account import ServiceAccountCredentials

scope=['https://www.googleapis.com/auth/spreadsheets', 
'https://wwww.googleapis.com/auth/drive']

credentials = ServiceAccountCredentials.from_json_keyfile_name('cred.json', scope)

gc = gspread.authorize(credentials)

wks = gc.open('datatest').Sheet1

print(wks.get_all_records)

但是我得到了这个错误

HttpAccessTokenRefreshError: invalid_scope: https://www.googleapis.com/auth/spreadsheets is not a valid audience string.

如何使用Google-auth代替gspread来处理这些数据?

python google-sheets-api google-authentication gspread
1个回答
3
投票

你输入4w !!!!

X'https://wwww.googleapis.com/auth/drive'

'Kua zxsw指向'

https://www.googleapis.com/auth/drive

希望它有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.