From 355557aa95834826b02ca8f1978e1e53c4288f5c Mon Sep 17 00:00:00 2001 From: Joe Gregorio Date: Mon, 2 Dec 2013 15:14:36 -0500 Subject: [PATCH] New Maps-Engine sample. Reviewed in https://codereview.appspot.com/36120043/. Index: samples/maps_engine/README =================================================================== new file mode 100644 --- samples/maps_engine/README | 8 +++ samples/maps_engine/maps_engine.py | Bin 0 -> 279 bytes samples/maps_engine/polygons.prj | Bin 0 -> 116 bytes samples/maps_engine/sample_tools.py | 96 ++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 samples/maps_engine/README create mode 100644 samples/maps_engine/maps_engine.py create mode 100644 samples/maps_engine/polygons.prj create mode 100644 samples/maps_engine/sample_tools.py diff --git a/samples/maps_engine/README b/samples/maps_engine/README new file mode 100644 index 0000000..4d6f150 --- /dev/null +++ b/samples/maps_engine/README @@ -0,0 +1,8 @@ +This sample code demonstrates use of Google Maps Engine. These samples do not +make use of the Discovery Service, but do use the the httplib2 library to make +authenticated requests. For more information on Google Maps Engine, see +developers.google.com/maps-engine/documentation/ + +api: mapsengine +keywords: maps engine mapsengine +author: Josh Livni diff --git a/samples/maps_engine/maps_engine.py b/samples/maps_engine/maps_engine.py new file mode 100644 index 0000000000000000000000000000000000000000..4eecb82f64946b65c22db8a4570b45d7b2349042 GIT binary patch literal 279 zcmZRMXP07PU|>jOhz63FATtFn<_BVN!MPAdN@{U3RLB`b2S7P6idO*+j7n0AODf@9 MYBCH#MpM&30O-3OVgLXD literal 0 HcmV?d00001 diff --git a/samples/maps_engine/polygons.prj b/samples/maps_engine/polygons.prj new file mode 100644 index 0000000000000000000000000000000000000000..152e8d3224a2d59d2a41890ea24acba6011b80b0 GIT binary patch literal 116 zcmZQzQ0HR64y;}XfrG@IaONFZOrcDGmm@##0i{L^)vB Pjv{IV. + client_secrets = os.path.join(os.path.dirname(filename), + 'client_secrets.json') + + # Set up a Flow object to be used if we need to authenticate. + flow = client.flow_from_clientsecrets( + client_secrets, + scope=scope, + message=tools.message_if_missing(client_secrets)) + + # Prepare credentials, and authorize HTTP object with them. + # If the credentials don't exist or are invalid run through the native client + # flow. The Storage object will ensure that if successful the good + # credentials will get written back to a file. + storage = oauth2client_file.Storage(name + '.dat') + credentials = storage.get() + if credentials is None or credentials.invalid: + credentials = tools.run_flow(flow, storage, flags) + http = credentials.authorize(http=httplib2.Http()) + + # GME does not publish a discovery document, so we return the auth'd http + # instead of building a service using the discovery module. + return (http, flags)