How to send a request to the URL that is set to "login: admin" in a Google application?

In my app.yaml, the url is defined as:

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

I tried the following code to talk with 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 the authentication failed and judging by the result, I am redirected to the login page.

How can I use python for authentication and URL access?

+6
source share
1 answer

login: admin instructs the Google App Engine to restrict URLs matching this pattern to authenticated users using Google. And they are the administrators of your Google App Engine project. With this limitation, standard HTTP basic authentication cannot be used. If you have a valid OAuth token token, you can pass it in the header in requests.get to handle the required authentication.

See this app article for some possible options: https://cloud.google.com/appengine/docs/python/appidentity/

+1
source

All Articles