Skip to content

Commit

Permalink
Changed auth token request method to POST (#1440)
Browse files Browse the repository at this point in the history
* changed request auth token request method to POST

* fix passing empty body

Co-authored-by: david.buniatyan@gmail.com <david.buniatyan@gmail.com>
  • Loading branch information
Diveafall and davidbuniat committed Jan 25, 2022
1 parent abc19ec commit b4ca1ff
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions hub/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,16 @@ def request(
requests.Response: The response received from the server.
"""
params = params or {}
data = data or {}
files = files or {}
json = json or {}
data = data or None
files = files or None
json = json or None
endpoint = endpoint or self.endpoint()
endpoint = endpoint.strip("/")
relative_url = relative_url.strip("/")
request_url = f"{endpoint}/{relative_url}"
headers = headers or {}
headers["hub-cli-version"] = self.version
headers["Authorization"] = self.auth_header

response = requests.request(
method,
request_url,
Expand All @@ -104,7 +103,7 @@ def request(
)

# clearer error than `ServerUnderMaintenence`
if "password" in json and json["password"] is None:
if json is not None and "password" in json and json["password"] is None:
# do NOT pass in the password here. `None` is explicitly typed.
raise InvalidPasswordException("Password cannot be `None`.")

Expand Down Expand Up @@ -133,7 +132,7 @@ def request_auth_token(self, username: str, password: str):
LoginException: If there is an issue retrieving the auth token.
"""
json = {"username": username, "password": password}
response = self.request("GET", GET_TOKEN_SUFFIX, json=json)
response = self.request("POST", GET_TOKEN_SUFFIX, json=json)

try:
token_dict = response.json()
Expand Down

0 comments on commit b4ca1ff

Please sign in to comment.