def login()

in CloudEndure.py [0:0]


def login(userapitoken, endpoint):
    login_data = {'userApiToken': userapitoken}
    r = requests.post(HOST + endpoint.format('login'),
                  data=json.dumps(login_data), headers=headers)
    if r.status_code != 200 and r.status_code != 307:
        if r.status_code == 401:
            print("ERROR: The login credentials provided cannot be authenticated....")
        elif r.status_code == 402:
            print("ERROR: There is no active license configured for this account....")
        elif r.status_code == 429:
            print("ERROR: Authentication failure limit has been reached. The service will become available for additional requests after a timeout....")
        sys.exit(1)

    # check if need to use a different API entry point
    if r.history:
        endpoint = '/' + '/'.join(r.url.split('/')[3:-1]) + '/{}'
        r = requests.post(HOST + endpoint.format('login'),
                      data=json.dumps(login_data), headers=headers)
                      
    session['session'] = r.cookies['session']
    try:
       headers['X-XSRF-TOKEN'] = r.cookies['XSRF-TOKEN']
    except:
       pass