Reputation: 1
SO, I'm using this code for the Compute Engine api. My question is that how can add my own credentials in this code instead of default credentials
here's the link: https://cloud.google.com/compute/docs/reference/rest/v1/targetPools/get
from pprint import pprint
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default()
service = discovery.build('compute', 'v1', credentials=credentials)
# Project ID for this request.
project = 'my-project' # TODO: Update placeholder value.
# Name of the region scoping this request.
region = 'my-region' # TODO: Update placeholder value.
# Name of the TargetPool resource to return.
target_pool = 'my-target-pool' # TODO: Update placeholder value.
request = service.targetPools().get(project=project, region=region, targetPool=target_pool)
response = request.execute()
# TODO: Change code below to process the `response` dict:
pprint(response)
Upvotes: 0
Views: 115
Reputation: 4913
Please see Authentication overview page for explanation of different ways to auth your requests along with with some code examples. See other pages from the menu on the left (best practices, auth with SA, auth with user creds and api keys) to get details.
Upvotes: 1