remote_api_shell.py与localhost dev_appserver

Bri*_*unt 2 python authentication google-app-engine

如何使用remote_shell_api.pydev_appserver.py(1.9.26+)开头的Google App Engine开发实例连接?

从命令行我得到:

$ remote_api_shell.py -s localhost:8080演示

...

urllib2.HTTPError:HTTP错误401:未授权太多auth尝试.

从具有以下内容的脚本运行时:

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
)
Run Code Online (Sandbox Code Playgroud)

一个得到:

google.appengine.tools.appengine_rpc.ClientLoginError:HTTP错误403:禁止

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

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

remote_api_stub.ConfigureRemoteApiForOAuth(server, path, secure=True)
Run Code Online (Sandbox Code Playgroud)

它会引发HTTPS错误.

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

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

有没有人解决过这个问题呢?

如报告所述:code.google.com/p/googleappengine问题12465

Bri*_*unt 5

答案是将远程api指向API服务器.当一个人启动appserver时,它会打印出这样的内容:

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
Run Code Online (Sandbox Code Playgroud)

然后可以连接例如

    remote_api_stub.ConfigureRemoteApi(
        None, path, fake_auth, servername=server,
        save_cookies=True, secure=False,
        rpc_server_factory=appengine_rpc.HttpRpcServer
    )
Run Code Online (Sandbox Code Playgroud)

哪里serverlocalhost:58262.

如果第一个参数不是None那么它似乎必须是dev~APPID(对于自己的APPID)

- 要么 -

更简单的版本:

remote_api_stub.ConfigureRemoteApiForOAuth(
        server.encode('ascii'), path, secure=not local
    )
Run Code Online (Sandbox Code Playgroud)

where server与上面相同,path是/_ah/remote和使用dev服务器时local设置的True.

如果server不是ASCII编码,则很难调试.