gpt4 book ai didi

python - 如何从脚本向应用引擎发出经过身份验证的请求?

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

如何从 python 脚本向 Appengine 发出经过身份验证的请求?我在网上找到了很多不同的方法,但都没有用。例如。 How do you access an authenticated Google App Engine service from a (non-web) python client?不起作用,请求返回登录页面。那篇文章很旧,也许从那以后发生了一些变化。有没有人有一个很好的包装对象来做到这一点?

最佳答案

回答了我自己的问题:

from google.appengine.tools import appengine_rpc
use_production = True
if use_production:
base_url = 'myapp.appspot.com'
else:
base_url = 'localhost:8080'


def passwdFunc():
return ('user@gmail.com','password')

def main(argv):
rpcServer = appengine_rpc.HttpRpcServer(base_url,
passwdFunc,
None,
'myapp',
save_cookies=True,
secure=use_production)
# Makes the actual call, I guess is the same for POST and GET?
blah = rpcServer.Send('/some_path/')

print blah

if __name__ == '__main__':
main(sys.argv)

关于python - 如何从脚本向应用引擎发出经过身份验证的请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10118585/

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