From 41fb06a70573a0c8bb2062918affc69b5feba50f Mon Sep 17 00:00:00 2001 From: Dina Graves Portman Date: Fri, 31 Jul 2020 16:55:51 -0700 Subject: [PATCH] Update render.py Removing the "unauthenticated mode" - it's no longer necessary now that we're using the google-auth library. --- run/markdown-preview/editor/render.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/run/markdown-preview/editor/render.py b/run/markdown-preview/editor/render.py index 22b6d562e464..8e6567bea2ff 100644 --- a/run/markdown-preview/editor/render.py +++ b/run/markdown-preview/editor/render.py @@ -31,18 +31,14 @@ def new_request(data): if not url: raise Exception("EDITOR_UPSTREAM_RENDER_URL missing") - unauthenticated = os.environ.get("EDITOR_UPSTREAM_UNAUTHENTICATED", False) - req = urllib.request.Request(url, data=data.encode()) credentials, project = google.auth.default() + auth_req = google.auth.transport.requests.Request() + target_audience = url - if not unauthenticated: - auth_req = google.auth.transport.requests.Request() - target_audience = url - - id_token = google.oauth2.id_token.fetch_id_token(auth_req, target_audience) - req.add_header("Authorization", f"Bearer {id_token}") + id_token = google.oauth2.id_token.fetch_id_token(auth_req, target_audience) + req.add_header("Authorization", f"Bearer {id_token}") response = urllib.request.urlopen(req) return response.read()