我编写了一个脚本,它应该在计算机上本地运行并修改一些 GAE 数据存储条目。这就是我连接到 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()
当我尝试对远程 API 进行身份验证时,只要我使用实际创建 appengine 的帐户,一切都会正常工作。在 GAE 权限中,我添加了第二个用户作为“所有者”,他接受了邀请,但由于某种原因,ConfigureREmoteApi 总是给出“无效的用户名或密码”。作为错误。我对第二个用户的密码进行了三次检查——这绝对是正确的。这是我得到的堆栈跟踪:
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
远程 api 访问是否仅限于创建 GAE 的用户?或者是否涉及一些身份验证令牌的缓存(例如在 urllib2 中)?