In order to get the enabled GCP-api services list, I am trying to get the service.list as per this HTTP request in this link.
Here's my code:
import json
from requests.auth import HTTPBasicAuth
import requests
from google.oauth2 import service_account
auth = HTTPBasicAuth('[email protected]','xyz....')
url = 'https://serviceusage.googleapis.com/v1/projects/my-proj-id123/services'
headers = {
"Accept": "application/json"
}
response = requests.request(
"GET",
url,
headers=headers,
auth=auth
)
# a=json.loads(response.text)
print(response.text)
But I am getting this error:
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"status": "PERMISSION_DENIED"
}
}
NOTE: I need a way to get the respond as per this link, either by service account or by api token . I have service account key (credential.json) but I don't know where to put for http request. kindly suggest me the procedures.
credentials.jsonshould be located in your home directory.