Add Auth Token to RuntimeEndpoint (#162)
This commit is contained in:
@@ -88,13 +88,18 @@ class HttpResponse:
|
||||
return self.resp.status
|
||||
|
||||
|
||||
def http_request(url, json=None, stream=False):
|
||||
def http_request(url, json=None, stream=False, auth_token=None):
|
||||
"""A faster version of requests.post with low-level urllib API."""
|
||||
if stream:
|
||||
return requests.post(url, json=json, stream=True)
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authentication": f"Bearer {auth_token}"
|
||||
}
|
||||
return requests.post(url, json=json, stream=True, headers=headers)
|
||||
else:
|
||||
req = urllib.request.Request(url)
|
||||
req.add_header("Content-Type", "application/json; charset=utf-8")
|
||||
req.add_header("Authentication", f"Bearer {auth_token}")
|
||||
if json is None:
|
||||
data = None
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user