Skip to content

Commit

Permalink
Fix: encode/decode bytestring for base64. (#4624)
Browse files Browse the repository at this point in the history
* Fix: encode/decode bytestring for base64.

* Apply b64encode fix to HiveHttp
  • Loading branch information
arikfr committed Feb 9, 2020
1 parent c961c33 commit f215947
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions redash/query_runner/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def _get_connection(self):
transport = THttpClient.THttpClient(http_uri)

password = self.configuration.get("http_password", "")
auth = base64.b64encode("token:" + password)
transport.setCustomHeaders({"Authorization": "Basic " + auth})
auth = base64.b64encode(b"token:" + password.encode("ascii"))
transport.setCustomHeaders({"Authorization": "Basic " + auth.decode()})

connection = hive.connect(thrift_transport=transport)
return connection
Expand Down
4 changes: 2 additions & 2 deletions redash/query_runner/hive_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ def _get_connection(self):
username = self.configuration.get("username", "")
password = self.configuration.get("http_password", "")
if username or password:
auth = base64.b64encode(username + ":" + password)
transport.setCustomHeaders({"Authorization": "Basic " + auth})
auth = base64.b64encode(username.encode("ascii") + b":" + password.encode("ascii"))
transport.setCustomHeaders({"Authorization": "Basic " + auth.decode()})

# create connection
connection = hive.connect(thrift_transport=transport)
Expand Down

0 comments on commit f215947

Please sign in to comment.