python appenginegcclient演示,本地devserver命中AccessTokenRefreshError(u'internal_failure',)

2024-04-29 00:07:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我在使用1.9.40(目前最新的)SDK的dev_appserver.py让python appengine gcs客户机演示工作遇到问题。在

我遵循了Setting Up Google Cloud StorageApp Engine and Google Cloud Storage Sample指令。在

我为一个付费应用创建了默认的bucket,启用了计费功能,并设置了非零的每日开支限制。我使用开发人员控制台成功地将一个文件上传到那个bucket。在

我从github克隆了GoogleCloudPlatform/appengine-gcs-clientrepo。我将python/src/cloudstorage目录复制到python/demo目录中,如下所示:

dancorn-laptop.acasa:/home/dancorn/src/appengine-gcs-client/python> find demo/ | sort
demo/
demo/app.yaml
demo/blobstore.py
demo/cloudstorage
demo/cloudstorage/api_utils.py
demo/cloudstorage/api_utils.pyc
demo/cloudstorage/cloudstorage_api.py
demo/cloudstorage/cloudstorage_api.pyc
demo/cloudstorage/common.py
demo/cloudstorage/common.pyc
demo/cloudstorage/errors.py
demo/cloudstorage/errors.pyc
demo/cloudstorage/__init__.py
demo/cloudstorage/__init__.pyc
demo/cloudstorage/rest_api.py
demo/cloudstorage/rest_api.pyc
demo/cloudstorage/storage_api.py
demo/cloudstorage/storage_api.pyc
demo/cloudstorage/test_utils.py
demo/__init__.py
demo/main.py
demo/main.pyc
demo/README

以下是我如何执行devserver,以及在尝试按指示访问http://localhost:8080时报告的错误:

^{pr2}$

当我看到有人试图联系Google服务器时,我很惊讶,我希望使用一个伪造的、基于本地文件系统的仿真,基于App Engine and Google Cloud Storage Sample指令中的注释:

You can use the client library with the development server.

**Note**: Files saved locally are subject to the file size and naming conventions imposed by the local filesystem.

You specify the project ID in the line application: your-app-id, replacing the value your-app-id. This value isn't used when running locally, but you must supply a valid project ID before deploying: the deployment utility reads this entry to determine where to deploy your app.

In your browser, visit https://.appspot.com; the application will execute on page load, just as it did when running locally. Only this time, the app will actually be writing to and reading from a real bucket.

我甚至把我真正的应用程序的ID放进了app.yaml文件中,但这没什么区别。在

我已经检查了已知的GAE问题,只发现了一个可能相关的问题,但是在一个旧的SDK版本上:

  • Issue 11690googleappengineelanucher开发服务器中存在GloudStorage错误

我检查了一些老的SDK版本(1.9.30,1.9.35),以防万一——也没什么区别。在

我的问题:

  1. 当GCS客户机与dev一起使用时,如何使它在本地操作(w/基于本地文件系统的伪造GCS)_appserver.py?在
  2. 因为它提到了它应该与真正的GCS一起工作,即使在与dev一起使用时也是如此_应用服务器.py我需要做些什么来达到这个目的?(不那么重要,更多的是好奇)

Tags: andthetopydevapiappyour
1条回答
网友
1楼 · 发布于 2024-04-29 00:07:08

事实上,原因是IMHO是一个相当愚蠢的bug——无法从早期版本的SDK(或相关包)编写的本地文件中读取凭证以及未能采取更为正当的行动,这将导致一个相当误导性的回溯,从而使调查无法进行。在

值得称赞的是这个答案:https://stackoverflow.com/a/35890078/4495081('这篇文章中提到的bug是由于其他原因,最终触发了类似的最终结果)

删除~/.config/gcloud/application_default_credentias.json文件后,演示使用本地文件系统成功完成。我真正的应用程序也运行得很好。在

我的第二个问题仍然存在,但我不太担心这个问题——我个人认为在本地开发服务器上使用真正的GCS存储没有太大的价值——无论如何,出于其他原因,我必须在一个真正的临时GAE应用程序上进行测试。在

相关问题 更多 >