8000 Allow basic auth as query strings · getbyrd/wc-api-python@83921db · GitHub
[go: up one dir, main page]

Skip to content

Commit 83921db

Browse files
Allow basic auth as query strings
1 parent 08d5197 commit 83921db

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

woocommerce/api.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def __init__(self, url, consumer_key, consumer_secret, **kwargs):
2626
self.is_ssl = self.__is_ssl()
2727
self.timeout = kwargs.get("timeout", 5)
2828
self.verify_ssl = kwargs.get("verify_ssl", True)
29+
self.query_string_auth = kwargs.get("query_string_auth", False)
2930

3031
def __is_ssl(self):
3132
""" Check if url use HTTPS """
@@ -60,14 +61,20 @@ def __request(self, method, endpoint, data):
6061
""" Do requests """
6162
url = self.__get_url(endpoint)
6263
auth = None
64+
params = {}
6365
headers = {
6466
"user-agent": "WooCommerce API Client-Python/%s" % __version__,
6567
"content-type": "application/json;charset=utf-8",
6668
"accept": "application/json"
6769
}
6870

69-
if self.is_ssl is True:
71+
if self.is_ssl is True and self.query_string_auth is False:
7072
auth = (self.consumer_key, self.consumer_secret)
73+
elif self.is_ssl is True and self.query_string_auth is True:
74+
params = {
75+
"consumer_key": self.consumer_key,
76+
"consumer_secret": self.consumer_secret
77+
}
7178
else:
7279
url = self.__get_oauth_url(url, method)
7380

@@ -79,6 +86,7 @@ def __request(self, method, endpoint, data):
7986
url=url,
8087
verify=self.verify_ssl,
8188
auth=auth,
89+
params=params,
8290
data=data,
8391
timeout=self.timeout,
8492
headers=headers

0 commit comments

Comments
 (0)
0