简体   繁体   English

如何将请求发送到谷歌应用引擎中设置为“login:admin”的网址?

[英]How to send request to url that is set to 'login:admin' in google app engine?

In my app.yaml, a url is defined to be: 在我的app.yaml中,网址被定义为:

- url: /api/.*
  script: main.app
  login: admin
  secure: always

I tried to the following code to talk to the api 我尝试使用以下代码与api交谈

import requests

def main():
    r = requests.get("https://test.appspots.com/api/get_data", auth=('me@me.com', 'password'))
    print r.status_code, r.text

if __name__ == '__main__':
    main()

But authentication has failed and, judging from the output, I am redirect to a login page. 但身份验证失败了,从输出判断,我重定向到登录页面。

How can I use python to authenticate and access the url? 如何使用python进行身份验证和访问URL?

login: admin instructs Google App Engine to restrict URLs matching the given pattern to users who are authenticated with Google AND are Administrators of your Google App Engine project. login: admin指示谷歌App Engine的限制的URL匹配给定模式谁是与谷歌的验证正在你的谷歌应用程序引擎项目的管理员用户。 There is no way to use standard HTTP Basic Authentication with this restriction. 无法使用具有此限制的标准HTTP基本身份验证。 If you have a valid oAuth Bearer token you can pass it in the header in requests.get to handle the required authentication. 如果您拥有有效的oAuth Bearer令牌,则可以在requests.get的标头中传递它以处理所需的身份验证。

See this article on appidentity for some possible options: https://cloud.google.com/appengine/docs/python/appidentity/ 有关可能的选项,请参阅有关适用性的文章: https ://cloud.google.com/appengine/docs/python/appidentity/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM