我正在尝试获取我的应用程序引擎上的驱动器文件列表。该应用程序不适用于应用程序以外的消费者,因此我没有为用户登录实现OAuth2。
我已经在GCP项目中启用了Drive,而compute实例是所有者。但是,我收到以下错误:
Traceback (most recent call last):
File "test.py", line 5, in <module>
credentials = app_engine.Credentials(scopes=SCOPES)
File "/usr/local/lib/python2.7/site-packages/google/auth/app_engine.py", line 105, in __init__
'The App Engine APIs are not available.')
EnvironmentError: The App Engine APIs are not available.
以下是我的代码(基于本教程:
https://developers.google.com/api-client-library/python/auth/service-accounts
):
from google.auth import app_engine
import googleapiclient.discovery
SCOPES = ['https://www.googleapis.com/auth/drive']
credentials = app_engine.Credentials(scopes=SCOPES)
project_id = 'project-id'
service = googleapiclient.discovery.build('drive', 'v3',credentials=credentials)
bucket = service.files().list(project=project_id).execute()
print bucket
我的证件有问题,我不确定是什么。
太长,读不下去了我如何授权我的应用引擎Flask应用程序(标准)使用Google API,包括Google Sheets、Drive、BigQuery和其他。请记住,这是一个服务器到服务器的作业。除应用程序本身外,没有其他用户登录。
最终,我尝试将Google Sheets中的值与BigQuery同步(该应用程序需要驱动器和BQ权限),然后将其推送到数据存储。
如果您对如何修复它有建议,请ELI5。