加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

如何从脚本生成经过身份验证的请求以进行appengine?

发布时间:2020-12-20 13:27:37 所属栏目:Python 来源:网络整理
导读:如何从 python脚本生成经过身份验证的请求以进行appengine?我在网上找到了很多不同的方法但没有工作. 例如. How do you access an authenticated Google App Engine service from a (non-web) python client?不起作用,请求返回登录页面. 这个帖子很旧,也许
如何从 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)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读