gpt4 book ai didi

python - remote_api_shell.py 与本地主机 dev_appserver

转载 作者:行者123 更新时间:2023-11-28 20:05:06 24 4
gpt4 key购买 nike

如何使用 remote_shell_api.py 进行连接到以 dev_appserver.py 开头的 Google App Engine 开发实例(1.9.26+)?

从命令行我得到:

$ remote_api_shell.py -s localhost:8080 demo

...

urllib2.HTTPError: HTTP Error 401: Unauthorized Too many auth attempts.

当从这样的脚本运行时:

from google.appengine.ext.remote_api import remote_api_stub
from google.appengine.tools import appengine_rpc

def fake_auth():
return ('pw', 'pass')
remote_api_stub.ConfigureRemoteApi(
None, path, fake_auth, servername=server,
save_cookies=True, secure=False,
rpc_server_factory=appengine_rpc.HttpRpcServer
)

一个人得到:

google.appengine.tools.appengine_rpc.ClientLoginError: HTTP Error 403: Forbidden

我已经通过 AppEngine 代码追溯,但不清楚是否(或如何)伪造对本地服务器的身份验证。

当我在代码中尝试 OAuth 时,例如

remote_api_stub.ConfigureRemoteApiForOAuth(server, path, secure=True)

它抛出 HTTPS 错误。

当我设置 secureFalse一个得到 urllib2.HTTPError: HTTP Error 401: Unauthorized Too many auth attempts.

看起来应该是一种向开发应用程序服务器进行身份验证的方法,因为在google.appengine.tools.appengine_rpc.py:347 有实现该效果的代码但我还没有收集到如何使用它。

有人解决过这个问题吗?

据报道:code.google.com/p/googleappengine Issue 12465

最佳答案

答案是将远程 api 指向 API 服务器。当启动应用程序服务器时,它会打印如下内容:

api_server.py:205] Starting API server at: http://localhost:58262
dispatcher.py:197] Starting module "default" running at: http://localhost:8080
admin_server.py:118] Starting admin server at: http://localhost:8081

然后可以连接到例如

    remote_api_stub.ConfigureRemoteApi(
None, path, fake_auth, servername=server,
save_cookies=True, secure=False,
rpc_server_factory=appengine_rpc.HttpRpcServer
)

serverlocalhost:58262

如果第一个参数不是None 那么它看起来一定是dev~APPID(对于自己的APPID)

— 或 —

一个更简单的版本:

remote_api_stub.ConfigureRemoteApiForOAuth(
server.encode('ascii'), path, secure=not local
)

其中server同上,路径为/_ah/remotelocal设置为True 使用开发服务器时。

如果 server 不是 ASCII 编码的,那么将发生难以调试的事情。 💀

关于python - remote_api_shell.py 与本地主机 dev_appserver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33264157/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com