Skip to content

Commit 20e97f4

Browse files
authored
Merge pull request #168 from mindsdb/feat/add-cookies
feat: add cookies to requests
2 parents 9826cc5 + 6a805c8 commit 20e97f4

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

mindsdb_sdk/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__title__ = 'mindsdb_sdk'
22
__package_name__ = 'mindsdb_sdk'
3-
__version__ = '3.1.6'
3+
__version__ = '3.1.7'
44
__description__ = "MindsDB Python SDK, provides an SDK to use a remote mindsdb instance"
55
__email__ = "[email protected]"
66
__author__ = 'MindsDB Inc'

mindsdb_sdk/connect.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def connect(
1212
password: str = None,
1313
api_key: str = None,
1414
is_managed: bool = False,
15+
cookies=None,
1516
headers=None) -> Server:
1617
"""
1718
Create connection to mindsdb server
@@ -21,6 +22,7 @@ def connect(
2122
:param password: user password to login (for cloud version)
2223
:param api_key: API key to authenticate (for cloud version)
2324
:param is_managed: whether or not the URL points to a managed instance
25+
:param cookies: addtional cookies to send with the connection, optional
2426
:param headers: addtional headers to send with the connection, optional
2527
:return: Server object
2628
@@ -51,6 +53,7 @@ def connect(
5153
# is local
5254
url = DEFAULT_LOCAL_API_URL
5355

54-
api = RestAPI(url, login, password, api_key, is_managed, headers=headers)
56+
api = RestAPI(url, login, password, api_key, is_managed,
57+
cookies=cookies, headers=headers)
5558

5659
return Server(api)

mindsdb_sdk/connectors/rest_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def _raise_for_status(response):
3737

3838

3939
class RestAPI:
40-
def __init__(self, url=None, login=None, password=None, api_key=None, is_managed=False, headers=None):
40+
def __init__(self, url=None, login=None, password=None, api_key=None, is_managed=False,
41+
cookies=None, headers=None):
4142

4243
self.url = url
4344
self.username = login
@@ -46,6 +47,9 @@ def __init__(self, url=None, login=None, password=None, api_key=None, is_managed
4647
self.is_managed = is_managed
4748
self.session = requests.Session()
4849

50+
if cookies is not None:
51+
self.session.cookies.update(cookies)
52+
4953
self.session.headers['User-Agent'] = f'python-sdk/{__about__.__version__}'
5054
if headers is not None:
5155
self.session.headers.update(headers)

0 commit comments

Comments
 (0)