Skip to content

Commit 2724792

Browse files
committed
Fix issue with params combined with redirection and auth forwarding
1 parent 475a2bc commit 2724792

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

python-lib/rest_api_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import requests
22
import time
3+
import copy
34
from pagination import Pagination
45
from safe_logger import SafeLogger
56
from loop_detector import LoopDetector
@@ -175,7 +176,10 @@ def request_with_redirect_retry(self, method, url, **kwargs):
175176
# If redirect_auth_header is true, another attempt is made with initial headers to the redirected url
176177
response = requests.request(method, url, **kwargs)
177178
if self.redirect_auth_header and not response.url.startswith(url):
178-
response = requests.request(method, response.url, **kwargs)
179+
redirection_kwargs = copy.deepcopy(kwargs)
180+
redirection_kwargs.pop("params", None) # params are contained in the redirected url
181+
logger.warning("Redirection ! Accessing endpoint {} with initial authorization headers".format(response.url))
182+
response = requests.request(method, response.url, **redirection_kwargs)
179183
return response
180184

181185
def paginated_api_call(self, can_raise_exeption=True):

0 commit comments

Comments
 (0)