我们在googleappengine应用程序中使用googledriveapi。 这个周末我们注意到它在更新电子表格标题方面有问题。我们得到以下错误:
HttpError: <HttpError 403 when requesting https://www.googleapis.com/drive/v2/files/1_X51WMK0U12rfPKc2x60E_EuyqtQ8koW-NSRZq7Eqdw?quotaUser=5660071165952000&fields=title&alt=json returned "The authenticated user has not granted the app 593604285024 write access to the file 1_X51WMK0U12rfPKc2x60E_EuyqtQ8koW-NSRZq7Eqdw">
其他对googledriveapi的调用也成功了。我们只是有这个问题。此外,这个功能正常工作了很长一段时间。有没有可能是谷歌方面的一些更新打破了这一点?你知道吗
再现问题的最低代码是:
class TestDriveUpdate(webapp2.RequestHandler):
def get(self):
credentials = StorageByKeyName(Credentials,
'103005000283606027776',
'credentials').get()
spreadsheet_key = '1_X51WMK0U12rfPKc2x60E_EuyqtQ8koW-NSRZq7Eqdw'
quota_user = '5660071165952000'
body = {"title": 'Test'}
fields = "title"
http = httplib2.Http(timeout=60)
credentials.authorize(http)
gdrive = apiclient.discovery.build('drive', 'v2', http=http)
response = gdrive.files().update(
fileId=spreadsheet_key,
body=body,
fields=fields,
quotaUser=quota_user
).execute()
self.response.write("OK")
基于此documentation,当请求应用程序不在文件的ACL上并且用户从未使用此驱动器应用程序显式打开文件时,会发生错误。找到这个SO question,它指出范围字符串必须在您的代码和管理控制台之间完全匹配,包括尾部斜杠等。还要确保域上允许使用驱动器应用程序(“允许用户安装Google驱动器应用程序”)。你知道吗
相关问题 更多 >
编程相关推荐