lsrestclient 3.0.2__tar.gz → 3.1.1__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {lsrestclient-3.0.2 → lsrestclient-3.1.1}/PKG-INFO +1 -1
- {lsrestclient-3.0.2 → lsrestclient-3.1.1}/lsrestclient/client.py +14 -2
- {lsrestclient-3.0.2 → lsrestclient-3.1.1}/pyproject.toml +1 -1
- {lsrestclient-3.0.2 → lsrestclient-3.1.1}/README.md +0 -0
- {lsrestclient-3.0.2 → lsrestclient-3.1.1}/lsrestclient/__init__.py +0 -0
- {lsrestclient-3.0.2 → lsrestclient-3.1.1}/lsrestclient/auth.py +0 -0
- {lsrestclient-3.0.2 → lsrestclient-3.1.1}/lsrestclient/contexts/__init__.py +0 -0
- {lsrestclient-3.0.2 → lsrestclient-3.1.1}/lsrestclient/contexts/bearer_token.py +0 -0
- {lsrestclient-3.0.2 → lsrestclient-3.1.1}/lsrestclient/exceptions.py +0 -0
- {lsrestclient-3.0.2 → lsrestclient-3.1.1}/lsrestclient/fixtures.py +0 -0
- {lsrestclient-3.0.2 → lsrestclient-3.1.1}/lsrestclient/mock.py +0 -0
- {lsrestclient-3.0.2 → lsrestclient-3.1.1}/lsrestclient/response.py +0 -0
@@ -63,12 +63,21 @@ class LsRestClient(Session):
|
|
63
63
|
self,
|
64
64
|
base_url: str = None,
|
65
65
|
name: str = "default",
|
66
|
+
headers: dict = None,
|
67
|
+
ignore_bearer_context: bool = False,
|
66
68
|
) -> None:
|
67
69
|
"""Class representing a REST client for JSON API."""
|
68
70
|
|
69
71
|
self._mocks = {}
|
70
72
|
self.base_url = base_url
|
73
|
+
self.ignore_bearer_context = ignore_bearer_context
|
71
74
|
self.base_headers = {"content-type": "application/json"}
|
75
|
+
|
76
|
+
with bearer_token_context() as bearer_token:
|
77
|
+
bearer_headers = {"Authorization": f"Bearer {bearer_token}"} if bearer_token is not None else {}
|
78
|
+
self.base_headers.update(bearer_headers)
|
79
|
+
if headers is not None:
|
80
|
+
self.base_headers.update(headers)
|
72
81
|
self.base_kwargs = {}
|
73
82
|
self.name = name
|
74
83
|
super().__init__()
|
@@ -162,9 +171,12 @@ class LsRestClient(Session):
|
|
162
171
|
Note: This method raises a `ConnectionError` if a connection error occurs during the request.
|
163
172
|
"""
|
164
173
|
# apply base_headers
|
165
|
-
|
166
174
|
with bearer_token_context() as bearer_token:
|
167
|
-
bearer_headers =
|
175
|
+
bearer_headers = (
|
176
|
+
{"Authorization": f"Bearer {bearer_token}"}
|
177
|
+
if bearer_token is not None and not self.ignore_bearer_context
|
178
|
+
else {}
|
179
|
+
)
|
168
180
|
|
169
181
|
headers = self.base_headers | bearer_headers | kwargs.get("headers", {})
|
170
182
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|