我花了一周时间好好工作,突然试图打开电子表格,我得到了以下错误:
RefreshError: ('invalid_client: Unauthorized', {'error': 'invalid_client', 'error_description': 'Unauthorized'})
以下是简单的使用方法:
gc = gspread.oauth(credentials_filename='credentials.json')
master="filename"
master_file_sh = gc.open(master)
使用google的方法,认证工作得很好,甚至多次尝试重置凭据,结果都没有成功。
知道为什么会失败吗?我知道信息清楚地说明了原因,但不可能是这样的。
任何建议都是欢迎的。
发布于 2022-10-04 15:32:38
我设法以不同的方式使用凭据来解决这个问题,而不是像下面这样重新分析后端:
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
import os
creds = None
if os.path.exists('token.json'):
creds = Credentials.from_authorized_user_file('token.json', scope)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
'credentials.json', scope)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
with open('token.json', 'w') as token:
token.write(creds.to_json())
gc=gspread.authorize(creds)
https://stackoverflow.com/questions/73908533
复制相似问题