Cannot access remote_api using oauth2

270 views
Skip to first unread message

Jeffrey Schiller

unread,
Jan 18, 2016, 9:50:06 PM1/18/16
to Google App Engine

I'm using the Python client side (version 1.9.31) against a Java server. Here is my shell output:

jis@jis:~$ gcloud auth list
Credentialed accounts:

To set the active account, run:
  $ gcloud config set account ``ACCOUNT''

jis@jis:~$ python -i /u1/SDK/google_appengine/remote_api_shell.py -p /remote_api jisqyvap4 
Traceback (most recent call last):
  File "/u1/SDK/google_appengine/remote_api_shell.py", line 133, in <module>
    run_file(__file__, globals())
  File "/u1/SDK/google_appengine/remote_api_shell.py", line 129, in run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/u1/SDK/google_appengine/google/appengine/tools/remote_api_shell.py", line 160, in <module>
    main(sys.argv)
  File "/u1/SDK/google_appengine/google/appengine/tools/remote_api_shell.py", line 156, in main
    oauth2=True)
  File "/u1/SDK/google_appengine/google/appengine/tools/remote_api_shell.py", line 74, in remote_api_shell
    secure=secure)
  File "/u1/SDK/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 768, in ConfigureRemoteApiForOAuth
    rpc_server_factory=rpc_server_factory)
  File "/u1/SDK/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 835, in ConfigureRemoteApi
    app_id = GetRemoteAppIdFromServer(server, path, rtok)
  File "/u1/SDK/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 569, in GetRemoteAppIdFromServer
    response = server.Send(path, payload=None, **urlargs)
  File "/u1/SDK/google_appengine/google/appengine/tools/appengine_rpc_httplib2.py", line 291, in Send
    NeedAuth()
  File "/u1/SDK/google_appengine/google/appengine/tools/appengine_rpc_httplib2.py", line 236, in NeedAuth
    RaiseHttpError(url, response_info, response, 'Too many auth attempts.')
  File "/u1/SDK/google_appengine/google/appengine/tools/appengine_rpc_httplib2.py", line 85, in RaiseHttpError
    raise urllib2.HTTPError(url, response_info.status, msg, response_info, stream)
urllib2.HTTPError: HTTP Error 302: Found Too many auth attempts.
>>> 

And here is how the Remote API is configured on the server (Java) side:

  <!-- Remote API -->
  <servlet>
    <display-name>Remote API Servlet</display-name>
    <servlet-name>RemoteApiServlet</servlet-name>
    <servlet-class>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>RemoteApiServlet</servlet-name>
    <url-pattern>/remote_api</url-pattern>
  </servlet-mapping>

(this is straight out of the documentation).

-Jeff

Adam (Cloud Platform Support)

unread,
Jan 18, 2016, 10:40:29 PM1/18/16
to Google App Engine
Do you happen to have any admin security constraints set in your web.xml as well?

Jeffrey Schiller

unread,
Jan 19, 2016, 12:00:44 AM1/19/16
to Google App Engine
Not on the /remote_api URL. There are other urls with admin constraints. Here is the definition in web.xml:

  <!-- Security constraint: require admin access for the appstats url -->
  <security-constraint>
    <web-resource-collection>
      <url-pattern>/appstats/*</url-pattern>
      <url-pattern>/convert/</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>admin</role-name>
    </auth-constraint>
  </security-constraint>

Just /appstats/* and /convert (which is part of our app).

Oh, but wait! I have another module which likely also uses /remote_api. It uses Python and may well ave the admin constraint. I'll finish this message and double check and post a follow up.

-Jeff

Jeffrey Schiller

unread,
Jan 19, 2016, 12:11:11 AM1/19/16
to Google App Engine
Well that didn't do it. I have two modules. The default module which is using the Java runtime and another module named "manhole" which uses the python runtime. They both defined /remote_api (but they don't share traffic, the the /remote_api on the Java module should be called). In any event I completely removed the /remote_api handler from manhole.yaml and the problem persists.

-Jeff

Adam (Cloud Platform Support)

unread,
Jan 22, 2016, 8:09:40 PM1/22/16
to Google App Engine
Just to be sure, are you connecting to a production app engine instance or a local dev server instance on some host? (I'm not certain if 'jisqyvap4' is filler or an actual hostname).
Reply all
Reply to author
Forward
0 new messages