Skip to content

Commit 4e41f31

Browse files
Merge pull request #208 from mindsdb/fix/new_mdb_auth
Support token-based MindsDB auth
2 parents 6e1a1f8 + 8ddda7f commit 4e41f31

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mindsdb_sdk/connectors/rest_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ def login(self):
8282

8383
_raise_for_status(r)
8484

85+
# Use newer MindsDB auth that uses a token
86+
if 'application/json' in r.headers.get('Content-Type', ''):
87+
resp_json = r.json()
88+
if isinstance(resp_json, dict) and "token" in resp_json:
89+
self.session.headers['Authorization'] = f'Bearer {resp_json["token"]}'
90+
8591
@_try_relogin
8692
def sql_query(self, sql, database=None, lowercase_columns=False):
8793

0 commit comments

Comments
 (0)