Hello Community,
I have been stuck with this failing API authentication call, I keep getting the exception error, I supplied the right variables and the authentications still keep failing not sure what I am doing wrong here. I am on dremio version 15 and connecting over a VPN, This API connection worked in the past. So confused on !
Any advanced inspection is greatly appreciated.
logger =logging.getLogger('dremioAPIcaller')
logger.setLevel(logging.DEBUG)
ch=logging.StreamHandler()
ch.setLevel(logging.DEBUG)
formatter =logging.Formatter('%(asctime)s-%(name)s -%(levelname)s-%(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
username = os.getenv('dremio_username')
password = os.getenv('dremio_pwd')
headers = {'content-type':'application/json'}
dremioServer = os.getenv('dremioUrl')
def login_token(username, password):
"""
This will return login authorizationlogin header
:param usrname => this is user login id
:param => pasword
"""
try:
loginData = {'userName': username, 'password': password}
response = requests.post('http://{}/apiv2/login'.format(dremioServer), headers=headers, data=json.dumps(loginData))
data = json.loads(response.text)
# retrieve the login token
token = data['token']
return {'content-type':'application/json', 'authorization':'_dremio{authToken}'.format(authToken=token)}
except:
logger.debug('check your connection settings')
headers =login_token(username, password)