Created
August 31, 2022 02:01
-
-
Save DazWilkin/57865536934e2f31981c48b12175f4e1 to your computer and use it in GitHub Desktop.
Stackoverflow: 73545312
This file contains 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
def generate_token(): | |
scopes = "https://www.googleapis.com/auth/cloud-platform" | |
url = f"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token?scopes={scopes}" | |
headers = {'Metadata-Flavor': 'Google'} | |
resp = requests.get(url, headers=headers) | |
j = resp.json() | |
token = j['access_token'] | |
return token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment