Skip to content

Commit 32f96e4

Browse files
authored
Update render.py (#4415)
Removing the "unauthenticated mode" - it's no longer necessary now that we're using the google-auth library.
1 parent 2024091 commit 32f96e4

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

run/markdown-preview/editor/render.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,14 @@ def new_request(data):
3131
if not url:
3232
raise Exception("EDITOR_UPSTREAM_RENDER_URL missing")
3333

34-
unauthenticated = os.environ.get("EDITOR_UPSTREAM_UNAUTHENTICATED", False)
35-
3634
req = urllib.request.Request(url, data=data.encode())
3735

3836
credentials, project = google.auth.default()
37+
auth_req = google.auth.transport.requests.Request()
38+
target_audience = url
3939

40-
if not unauthenticated:
41-
auth_req = google.auth.transport.requests.Request()
42-
target_audience = url
43-
44-
id_token = google.oauth2.id_token.fetch_id_token(auth_req, target_audience)
45-
req.add_header("Authorization", f"Bearer {id_token}")
40+
id_token = google.oauth2.id_token.fetch_id_token(auth_req, target_audience)
41+
req.add_header("Authorization", f"Bearer {id_token}")
4642

4743
response = urllib.request.urlopen(req)
4844
return response.read()

0 commit comments

Comments
 (0)