Skip to content
This repository was archived by the owner on Oct 14, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions ox3apiclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
API_PATH_V2 = '/ox/4.0'
API_PATH_SSO = '/api'
ACCEPTABLE_PATHS = (API_PATH_V1, API_PATH_V2, API_PATH_SSO)
JSON_PATHS = (API_PATH_V2)
JSON_PATHS = (API_PATH_V2,)
HTTP_METHOD_OVERRIDES = ['DELETE', 'PUT', 'OPTIONS']


Expand All @@ -60,7 +60,7 @@ class Client(object):
of Python dictionaries, translated to and from the JSON and
query string encoding the API itself uses.

"""
"""


def __init__(self, domain, realm, consumer_key, consumer_secret,
Expand Down Expand Up @@ -92,7 +92,7 @@ def __init__(self, domain, realm, consumer_key, consumer_secret,
headers -- list of headers to send with the request
timeout -- http request timeout in seconds.
"""

self.domain = domain
self.consumer_key = consumer_key
self.consumer_secret = consumer_secret
Expand All @@ -103,7 +103,7 @@ def __init__(self, domain, realm, consumer_key, consumer_secret,
self.authorization_url = authorization_url
self.api_path = api_path
self.timeout = timeout

# Validate API path:
if api_path not in ACCEPTABLE_PATHS:
msg = '"{}" is not a recognized API path.'.format(api_path)
Expand Down Expand Up @@ -339,13 +339,13 @@ def get(self, url):
return response.json()
except:
return response.content

def options(self, url):
"""Send a request with HTTP method OPTIONS to the given
URL or API shorthand.

OX3 v2 uses this method for showing help information.

"""
response = self._session.options(self._resolve_url(url), timeout=self.timeout)
self.log_request(response)
Expand Down Expand Up @@ -389,7 +389,7 @@ def post(self, url, data=None):

def delete(self, url):
"""Issue a DELETE request to the URL or API shorthand."""
response = requests.delete(self._resolve_url(url))
response = self._session.delete(self._resolve_url(url))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use _session to send the request, or we'll get 401 unauthorized error

self.log_request(response)
response.raise_for_status()
# Catch no content responses from some delete actions.
Expand Down