Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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

I tried to the following code to talk to the api

import requests

def main():
    r = requests.get("https://test.appspots.com/api/get_data", auth=('[email protected]', '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?

like image 231
Anthony Kong Avatar asked Jul 11 '15 05:07

Anthony Kong


People also ask

How do I change my App Engine URL?

In the Google Cloud console, go to the Custom Domains tab of the App Engine Settings page. Click Add a custom domain. If your domain is already verified, the domain appears in the Select the domain you want to use section. Select the domain from the drop-down menu and click Continue.

How do I enable App Engine Admin API?

To access the App Engine APIs Explorer tool, open up the navigation menu and select APIs & Services > Library. In the search bar, enter in App Engine and select the App Engine Admin API from the results list. Make sure that API is enabled, if not click Enable.

Which is a command to deploy the application in the Google App Engine?

App Engine provides the gcloud app deploy command, which builds an image with your source code and deploys that image on App Engine. You can use the cloud-sdk image as a build step in your config file to invoke gcloud commands within the image.


1 Answers

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. There is no way to use standard HTTP Basic Authentication with this restriction. If you have a valid oAuth Bearer token you can pass it in the header in requests.get to handle the required authentication.

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

like image 191
Josh J Avatar answered Sep 23 '22 21:09

Josh J