Reputation: 83
How do I make an authenticated request from a python script to appengine? I have found lots of different methods on the web but none work. E.G. How do you access an authenticated Google App Engine service from a (non-web) python client? doesn't work, the request returns the login page. That post is old, maybe something changed since then. Has anyone got a nice wrapped object to do this?
Upvotes: 4
Views: 382
Reputation: 83
Answered my own question:
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 ('[email protected]','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)
Upvotes: 1
Reputation: 503
You can see one example of a non-web authenticated python client making requests in the Python client library used to process GAE Pull Queues at https://developers.google.com/appengine/docs/python/taskqueue/overview-pull#Using_the_Task_Queue_REST_API_with_the_Python_Google_API_Library
Upvotes: 0