【发布时间】:2018-03-25 18:07:30
【问题描述】:
我正在使用 google 的驱动器 API 构建一个应用程序,并且我正在使用 JSON API 密钥。每当我运行以下代码时:
# these are api managing credentials
scope = ['https://spreadsheets.google.com/spreadsheets']
creds = ServiceAccountCredentials.from_json('client_secret', scope)
client = gspread.authorize(creds) # this connects the the google api using credentials
我收到这条奇怪的错误消息:
File "C:/Users/Will Kaiser's PC/Documents/PyCharm/Projects/ph/main.py", line 16, in <module>
creds = ServiceAccountCredentials.from_json('client_secret.json', scope)
TypeError: from_json() takes 2 positional arguments but 3 were given
这对我来说是一个非常奇怪的错误,因为我给函数提供了 2 个参数。我的密钥在 JSON 文件中,所有这些都正确完成。
【问题讨论】:
标签: python json google-sheets oauth2client