提问人:Artem-klimov 提问时间:11/12/2023 更新时间:11/12/2023 访问量:13
在主机上对 Google Disk API 进行身份验证
authentication of the google disk api on the hosting
问:
我有一个电报机器人,有一个将文件发送到 Google 驱动器的功能。当我在本地测试时,它运行良好,在我上传到远程主机后,日志中的所有内容都出现了错误
授权代码如下所示:
def getCreds():
creds = None
SCOPES = ['https://www.googleapis.com/auth/drive.file']
secrets_file = 'client_secrets.json'
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
# I ran this code for local use
# flow = InstalledAppFlow.from_client_secrets_file(
# 'client_secrets.json', SCOPES)
# creds = flow.run_local_server(port=8080)
# creds, _ = flow.authorization_url()
# flow.fetch_token(code='')
creds = Credentials.from_authorized_user_file(secrets_file)
with open('token.pickle', 'wb') as token:
pickle.dump(creds, token)
return creds
代码应该是什么样子才能在远程服务器上正常工作?
答: 暂无答案
评论