with requests.Session() as s: s.auth = auth crumb = s.get(jenkins_url + "crumbIssuer/api/json").json()['crumb'] s.headers.update({"token": token, "Jenkins-Crumb": crumb})