Last active
June 11, 2020 14:51
-
-
Save anchitarnav/ecb6ced3de981266193b83d7e17c4cf5 to your computer and use it in GitHub Desktop.
Doing an Google Cloud Platform / GCP / GCLOUD API Call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
API_TO_HIT = "https://apikeys.googleapis.com/v2alpha1/projects/your-project-id/keys" | |
from google.auth.transport.requests import AuthorizedSession | |
from google.auth import default | |
# Assuming GOOGLE_APPLICATION_CREDENTIALS env variable is set | |
credentials, default_project_id = default(scopes=['https://www.googleapis.com/auth/cloud-platform']) | |
session = AuthorizedSession(credentials) | |
res = session.get(API_TO_HIT) | |
print(res, res.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment