5/10/2018 - 10:08 AM

get api token arcsight

def get_token():
    Every request, this method will be called and generate new api_key using the username and password as the parameter that were defined in the .env file
    api_token = ""
        # Login request url with username and password as a parameter
        login_url = url + "/www/core-service/rest/LoginService/login?login=%s&password=%s" % (
            settings.ARCSIGHT_USERNAME, settings.ARCSIGHT_PASSWORD)

        # Make a get request to login and get the api_token key
        login = requests.get(login_url, verify=settings.ARCSIGHT_CERT)

        response_json = parse_to_json(login)
        api_token = json.loads(response_json)['ns3:loginResponse']['ns3:return']
    except Exception as e:
        # print(e)
        return api_token

    a_token = AuthToken(auth_token=api_token)

    return api_token