我试图打开用python/django编写的应用程序发送的文件。用于创建空白文档的Usin文档链接 --我试图传输要在google中打开的现有文件。
views.py
SCOPES = ['https://www.googleapis.com/auth/documents.readonly']
def file_to_gd_docs(import_file=None):
....
#authorization part(success)
....
service = build('docs', 'v1', credentials=creds)
title = 'My Document'
body = {
'title': title
}
doc = service.documents().create(body=import_file).execute()
print('Created document with title: {0}'.format(
doc.get('title')))我将import_file的值作为变量body的值,然后得到一个错误
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://docs.googleapis.com/v1/documents?alt=json returned "Request had insufficient authentication scopes.">如何正确地将外部文件传输到google文档以供打开?
发布于 2019-09-11 13:28:11
Documents.create需要下列作用域之一

您使用的是https://www.googleapis.com/auth/documents.readonly,这会给您提供错误
请求没有足够的身份验证范围。
解决方案
将范围更改为所需的范围之一,并再次请求用户的访问。
发布于 2020-04-03 09:32:25
这取决于你为什么想要这个。以上是使用google的api的正确方法,但您也可以使用以下黑客:
url = https://docs.google.com/document/u/0/ webbrowser.open(url)
然后使用pyautogui最大化或平铺窗口,然后单击new。这只适用于一个大小的显示器。如果您移动到另一个系统,则需要更改pyautogui单击的位置。另外,如果谷歌改变页面布局,它可能会崩溃。
当我想口述一个音符的时候,我会和我的语音助理一起做这个。这只是为了我,而不是为了分配;那为什么不呢?我不希望我的api密钥出现在github上。对于许多共享代码但需要api密钥的人来说,这是一个痛苦的问题。
https://stackoverflow.com/questions/57890229
复制相似问题