in vpc-sample/main.py [0:0]
def get_hello_world(request):
try:
url = os.environ.get("URL")
req = urllib.request.Request(url)
auth_req = google.auth.transport.requests.Request()
id_token = google.oauth2.id_token.fetch_id_token(auth_req, url)
req.add_header("Authorization", f"Bearer {id_token}")
response = urllib.request.urlopen(req)
return response.read()
except Exception as e:
print(e)
return str(e)