AttributeError(“'凭据'对象没有属性'请求'”)

问题描述 投票:0回答:1

我们的应用程序必须使用 Google Doc API 创建/编写 Google 文档。根据文档here,我们 1) 在 Google Cloud Console 中启用了我们的 API。然后我们定义 API 调用的范围。

self.GOOGLEDOCUMENTS_SCOPES = ['https://www.googleapis.com/auth/spreadsheets','https://www.googleapis.com/auth/documents','https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/drive.file']

然后我们创建凭证

document_credentials, document_project_id     = auth.default(scopes=self.GOOGLEDOCUMENTS_SCOPES)

然后我们构建发现服务

document_service                = build('docs', 'v1', self.document_credentials)

然后我们调用 api 来创建 google 文档。

document_service.documents().create(body=body).execute()

我们收到以下错误 -

AttributeError("'Credentials' object has no attribute 'request'")
google-app-engine google-api google-oauth google-docs-api
1个回答
0
投票

在你的展示脚本中,做如下修改怎么样?

来自:

document_service                = build('docs', 'v1', self.document_credentials)

致:

document_service = build('docs', 'v1', credentials=self.document_credentials)
© www.soinside.com 2019 - 2024. All rights reserved.