import requests

def get_token(username, password):
    """
    Function to retrieve the token, this should not be modified
    """
    url = "https://olida.ibsquare.be/api-token/" # do not touch this
    response = requests.post(url, data={'username': username, 'password': password}).json()
    try:
        token = response['token']
    except KeyError:
        print("Something went wrong during the token retrieval, try to check your credentials")
        token = ''
    return token

def get_info(token):
    url = 'https://olida.ibsquare.be/api/combinations/' # put here the API endpoint you wish to access. The example will give a list of all the combinations in OLIDA
    header = {'Authorization': f'Token {token}'}

    response = requests.get(url, headers=header).json()
    print(response)


if __name__ == "__main__":
    username = input("Username for OLIDA : ")
    password = input ("Password : ")
    token = get_token(username,password)
    if token != '':
        get_info(token)