Skip to content

Commit

Permalink
Merge pull request #191 from keboola/fix/SUPPORT-8272-query-string-wi…
Browse files Browse the repository at this point in the history
…th-multiple-params

SUPPORT-8272 fix query string when contains more params
  • Loading branch information
kudj authored Oct 24, 2024
2 parents 062a868 + 366d830 commit 954663d
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit 954663d

Please sign in to comment.