diff options
author | Orest Bolohan <orest@google.com> | 2014-07-11 13:09:18 -0700 |
---|---|---|
committer | Orest Bolohan <orest@google.com> | 2014-07-11 13:09:18 -0700 |
commit | df59cadb0398bae43b762d45dfa229127ffa734d (patch) | |
tree | deb4fbc18f99839e51f4cd72c27059d414543893 /samples | |
parent | d02b317af0313dcf66755844f5421651af5eb356 (diff) | |
download | oauth2client-df59cadb0398bae43b762d45dfa229127ffa734d.tar.gz |
Replace the 'default credentials' concept with the 'application default credentials' concept.
Diffstat (limited to 'samples')
-rw-r--r-- | samples/call_compute_service.py | 9 | ||||
-rw-r--r-- | samples/googleappengine/call_compute_service_from_gae.py | 9 |
2 files changed, 10 insertions, 8 deletions
diff --git a/samples/call_compute_service.py b/samples/call_compute_service.py index aaa4f38..a8e42c6 100644 --- a/samples/call_compute_service.py +++ b/samples/call_compute_service.py @@ -1,13 +1,14 @@ -# To be used to test GoogleCredential.GetDefaultCredential() +# To be used to test GoogleCredentials.get_application_default() # from local machine and GCE. from googleapiclient.discovery import build from oauth2client.client import GoogleCredentials -PROJECT = "bamboo-machine-422" # Provide your own GCE project here -ZONE = "us-central1-a" # Put here a zone which has some VMs +PROJECT = 'bamboo-machine-422' # Provide your own GCE project here +ZONE = 'us-central1-a' # Put here a zone which has some VMs -service = build("compute", "v1", credentials=GoogleCredentials.get_default()) +credentials = GoogleCredentials.get_application_default() +service = build('compute', 'v1', credentials=credentials) request = service.instances().list(project=PROJECT, zone=ZONE) response = request.execute() diff --git a/samples/googleappengine/call_compute_service_from_gae.py b/samples/googleappengine/call_compute_service_from_gae.py index e2b01d2..b3e3e75 100644 --- a/samples/googleappengine/call_compute_service_from_gae.py +++ b/samples/googleappengine/call_compute_service_from_gae.py @@ -1,15 +1,16 @@ -# To be used to test GoogleCredential.GetDefaultCredential() +# To be used to test GoogleCredentials.get_application_default() # from devel GAE (ie, dev_appserver.py). import webapp2 from googleapiclient.discovery import build from oauth2client.client import GoogleCredentials -PROJECT = "bamboo-machine-422" # Provide your own GCE project here -ZONE = "us-central1-a" # Put here a zone which has some VMs +PROJECT = 'bamboo-machine-422' # Provide your own GCE project here +ZONE = 'us-central1-a' # Put here a zone which has some VMs def get_instances(): - service = build("compute", "v1", credentials=GoogleCredentials.get_default()) + credentials = GoogleCredentials.get_application_default() + service = build('compute', 'v1', credentials=credentials) request = service.instances().list(project=PROJECT, zone=ZONE) return request.execute() |