How to Authenticate Appegine API Access (Python)

I wrote a script that needs to run locally on the computer and modify some of the GAE datastore entries. This is how I connect to my GAE:

def auth_func():
   return ('username@gmail.com','topsecret')
   #return ('seconduser@gmail.com','topsecret2')

def connect():
   remote_api_stub.ConfigureRemoteApi(None,'/_ah/remote_api', auth_func, 'myapp.appspot.com', secure=True)
   remote_api_stub.MaybeInvokeAuthentication()

      

When I try to authenticate to the remote API everything works fine as long as I use the account that actually created the application. In the GAE permissions, I added a second user as "owner" who accepted the invitation, but for some reason ConfigureREmoteApi always gives "Invalid username or password". as a mistake. I checked the password for the second user three times - it is definitely correct. This is the stack trace I am getting:

Invalid username or password.
Invalid username or password.
Invalid username or password.
Traceback (most recent call last):
  File "./create_updater_entry.py", line 182, in <module>
    remote_api_stub.MaybeInvokeAuthentication()
  File "c:/Program Files (x86)/Google/google_appengine\google\appengine\ext\remote_api\remote_api_stub.py", line 740, in MaybeInvokeAuthentication
    datastore_stub._server.Send(datastore_stub._path, payload=None)
  File "c:/Program Files (x86)/Google/google_appengine\google\appengine\tools\appengine_rpc.py", line 405, in Send
    f = self.opener.open(req)
  File "c:\WinPython-32bit-2.7.6.4\python-2.7.6\lib\urllib2.py", line 410, in open
    response = meth(req, response)
  File "c:\WinPython-32bit-2.7.6.4\python-2.7.6\lib\urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "c:\WinPython-32bit-2.7.6.4\python-2.7.6\lib\urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "c:\WinPython-32bit-2.7.6.4\python-2.7.6\lib\urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "c:\WinPython-32bit-2.7.6.4\python-2.7.6\lib\urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Unauthorized

      

Is access to remote api restricted to user who created GAE? Or is there any caching of authentication tokens (like in urllib2)?

+3


source to share


1 answer


I solved this by enabling "access for less secure apps" in my google account settings: https://www.google.com/settings/u/1/security/lesssecureapps



+4


source







All Articles