1# To be used to test GoogleCredentials.get_application_default() 2# from local machine and GCE. 3# The GCE virtual machine needs to have both service account and 4# Compute API enabled. 5# See: https://developers.google.com/compute/docs/authentication 6 7from googleapiclient.discovery import build 8 9from oauth2client.client import GoogleCredentials 10 11 12PROJECT = 'bamboo-machine-422' # Provide your own GCE project here 13ZONE = 'us-central1-a' # Put here a zone which has some VMs 14 15 16credentials = GoogleCredentials.get_application_default() 17service = build('compute', 'v1', credentials=credentials) 18 19request = service.instances().list(project=PROJECT, zone=ZONE) 20response = request.execute() 21 22print(response) 23