Python 在代码中添加自己的凭据而不是使用默认凭据:Google Compute Api
因此,我将此代码用于计算引擎api。我的问题是,如何在此代码中添加我自己的凭据而不是默认凭据 以下是链接: 请参阅第页,了解验证请求的不同方法的说明以及一些代码示例。查看左侧菜单中的其他页面(最佳实践、使用SA进行身份验证、使用用户凭据和api密钥进行身份验证)以获取详细信息Python 在代码中添加自己的凭据而不是使用默认凭据:Google Compute Api,python,api,google-compute-engine,gcloud,credentials,Python,Api,Google Compute Engine,Gcloud,Credentials,因此,我将此代码用于计算引擎api。我的问题是,如何在此代码中添加我自己的凭据而不是默认凭据 以下是链接: 请参阅第页,了解验证请求的不同方法的说明以及一些代码示例。查看左侧菜单中的其他页面(最佳实践、使用SA进行身份验证、使用用户凭据和api密钥进行身份验证)以获取详细信息 from pprint import pprint from googleapiclient import discovery from oauth2client.client import GoogleCredentia
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)