Skip to content

Commit

Permalink
Update render.py (#4415)
Browse files Browse the repository at this point in the history
Removing the "unauthenticated mode" - it's no longer necessary now that we're using the google-auth library.
  • Loading branch information
dinagraves authored Aug 1, 2020
1 parent 2024091 commit 32f96e4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions run/markdown-preview/editor/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 32f96e4

Please sign in to comment.