"""Read the authenticated workspace. No paid work or retries. Set WAVEFORM_ORIGIN and WAVEFORM_API_KEY privately in your environment. """ import json import os import urllib.error import urllib.request class NoRedirect(urllib.request.HTTPRedirectHandler): def redirect_request(self, req, fp, code, msg, headers, newurl): return None origin = os.environ["WAVEFORM_ORIGIN"].rstrip("/") key = os.environ["WAVEFORM_API_KEY"] request = urllib.request.Request(origin + "/api/v1/identity", headers={"Authorization": "Bearer " + key}) try: with urllib.request.build_opener(NoRedirect).open(request, timeout=30) as response: print(json.dumps(json.load(response), indent=2)) except urllib.error.HTTPError as error: print("Request rejected:", error.code, error.read().decode("utf-8")) except urllib.error.URLError: print("Request failed. Read saved state before retrying a mutation.")