gpt4 book ai didi

python - 如何验证 Google Appegine (Python) 远程 API 访问

转载 作者:太空宇宙 更新时间:2023-11-03 15:10:24 25 4
gpt4 key购买 nike

我编写了一个脚本,该脚本应该在计算机上本地运行并修改一些 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 进行身份验证时,只要我使用实际创建应用引擎的帐户,一切都会正常进行。在 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 的用户?或者是否涉及一些身份验证 token 的缓存(例如在 urllib2 中)?

最佳答案

我通过在 Google 帐户设置中启用“访问安全性较低的应用程序”解决了这个问题:https://www.google.com/settings/u/1/security/lesssecureapps

关于python - 如何验证 Google Appegine (Python) 远程 API 访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27510527/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com