Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SUPPORT-8272 fix query string when contains more params #191

Merged
merged 2 commits into from
Oct 24, 2024
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
9 changes: 7 additions & 2 deletions python-sync-actions/src/http_generic/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
from abc import ABC, abstractmethod
from typing import Callable, Union, Dict, Literal
from urllib.parse import urlencode
from urllib.parse import urlparse, parse_qs, urlencode, urlunparse

import requests
from requests import auth
Expand Down Expand Up @@ -167,7 +167,12 @@ def __call__(self, r):
r.headers[self.key] = f"{self.token}"

elif self.position == 'query':
r.url = f"{r.url}?{urlencode({self.key: self.token})}"
parsed_url = urlparse(r.url)
query_params = parse_qs(parsed_url.query)
query_params.update({self.key: self.token})
new_query = urlencode(query_params, doseq=True)
r.url = urlunparse(parsed_url._replace(query=new_query))

else:
raise AuthBuilderError(f"Unsupported position {self.position} for API Key auth method")
return r
Expand Down
Loading