【问题标题】:appcfg.py upload_data won't ask for authentication locallyappcfg.py upload_data 不会在本地要求身份验证
【发布时间】:2016-10-18 03:46:50
【问题描述】:

在本地开发环境中,upload_data 命令不会启动 OAuth 浏览器。为什么会这样?!?

代码在 App Engine 上运行良好,但在本地开发环境中运行良好。在开发环境中使用远程 API 是否有技巧。

这是我如何使用命令...

appcfg.py upload_data --config_file=bulkloader.yaml --filename=./stops.txt --kind=StopLocationLoader --url=http://localhost:8082/_ah/remote_api
10:39 PM Uploading data records.
[INFO    ] Logging to bulkloader-log-20161017.223916
[INFO    ] Throttling transfers:
[INFO    ] Bandwidth: 250000 bytes/second
[INFO    ] HTTP connections: 8/second
[INFO    ] Entities inserted/fetched/modified: 20/second
[INFO    ] Batch Size: 10
Error 401: --- begin server output ---
You must be logged in as an administrator to access this.
--- end server output ---

【问题讨论】:

    标签: google-app-engine bulkloader


    【解决方案1】:

    这是一个错误:https://code.google.com/p/googleappengine/issues/detail?id=12445

    它链接到为another question 发布的解决方法:

    gcloud auth login
    gcloud auth print-access-token
    appcfg.py upload_data --oauth2_access_token=<oauth2_access_token> --config_file bulkloader.yaml --url=http://<yourproject>.appspot.com/remote_api --filename places.csv --kind=Place --email=<you@gmail.com>
    

    【讨论】:

    • 您的示例使用了 appspot.com 域。故意的?我在应用程序引擎上使用批量加载程序没有问题。仅在本地开发环境中。
    • 我已经尝试使用您的解决方案并指向本地主机,但错误有所不同。现在我得到一个 401 错误,“错误”:“invalid_grant”
    • 你说得对,我把它弄混了!但是,该问题的链接确实是正确的。如果您使用 Python 甚至是 one for Java,它为开发服务器提供 several workarounds。告诉我这是否有帮助,在这种情况下,我会相应地更新我的答案。
    • 我已经更新了答案,但不幸的是我仍然无法让该解决方案正常工作。
    猜你喜欢
    • 2017-09-14
    • 2019-12-02
    • 1970-01-01
    • 2021-12-09
    • 2011-02-23
    • 1970-01-01
    • 1970-01-01
    • 2021-10-10
    • 1970-01-01
    相关资源
    最近更新 更多