Login API authentication failure

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)

@iskidet Jus to narrow down the issue, if you login using the username/password that gets passed to your script but using the UI, does it work?

The credentials works perfectly when I login in the UI

@iskidet just change data=json.dumps(loginData) to json = loginData

@hl-nahuz

Do you mean to say

data=json.loginData

I am wondering what get passed to token if I write

json=loginData

Just do:

response = requests.post('http://{}/apiv2/login'.format(dremioServer), headers=headers, json = loginData)

For some reason dremio can´t parse json object. Just check if you loginData looks like a python dict

{
¨username¨:¨some_user¨,
¨password¨:¨some_pass¨
}