I want to create a Google Cloud project using Google Cloud API Python client.
Steps:
- Run
gcloud beta auth application-default logincommand to get application default credentials by login onto the browser. - Enable Resource Manager API on my GCP console.
Here's the working Python code:
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
...
credentials = GoogleCredentials.get_application_default()
service = discovery.build('cloudresourcemanager', 'v1', credentials=credentials)
project_body = {
'name': 'Api Project',
'projectId': 'api-9837'
}
request = service.projects().create(body=project_body)
request.execute()
pprint(request)
But I can't take the first step.