Access an App Engine app from command line using O

2019-02-11 05:25发布

I have an App Engine site with a URL which is marked login:required in app.yaml. I need to access this URL from a command-line script. How do I do that now that OAuth2 has replaced ClientLogin?

Previous questions () all end up using ClientLogin, which has been removed:

OAuth2 is the replacement, but when I try to use that, my script continually gets redirected to the login page.

Can anyone see what I'm doing wrong?

from google.appengine.tools import appengine_rpc_httplib2

authParams = appengine_rpc_httplib2.HttpRpcServerOAuth2.OAuth2Parameters(
  access_token=None,
  # id & secret come from http://console.developers.google.com
  client_id="FIXME",
  client_secret="FIXME",
  # I'm not sure this is the right scope
  scope="https://www.googleapis.com/auth/appengine.admin",
  refresh_token=None,
  credential_file=None
)
rpcServer = appengine_rpc_httplib2.HttpRpcServerOAuth2('example.appspot.com',
                                                       authParams,
                                                       None,
                                                       'ignored',
                                                       save_cookies=False,
                                                       auth_tries=3)
# Makes the actual GET request
result = rpcServer.Send('/some_url/', payload=None)
print result

(I'm using python but I'd be open to any way to do this from the command-line, even curl.)

0条回答
登录 后发表回答