How to authenticate in Jenkins while remotely accessing its JSON API?
<p>I need to access the Jenkins JSON API from a Python script. The problem is that our Jenkins installation is secured so to log in users have to select a certificate. Sadly, in Jenkins <a href="https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API" rel="nofollow">Remote Access Documentation</a> they don't mention a thing about certificates and I tried using the API Token without success.</p>

<p>How can I get to authenticate from a Python script to use their JSON API?</p>

<p>Thanks in advance!</p>

<p>You have to authenticate to the JSON API using HTTP Basic Auth. </p>

<blockquote>
  <p>To make scripted clients (such as wget) invoke operations that require authorization (such as scheduling a build), use HTTP BASIC authentication to specify the user name and the API token. This is often more convenient than emulating the form-based authentication</p>
</blockquote>

<p><a href="https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients" rel="nofollow">https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients</a></p>

<p>Here is a sample of using Basic Auth with Python. </p>

<p><a href="http://docs.python-requests.org/en/master/user/authentication/" rel="nofollow">http://docs.python-requests.org/en/master/user/authentication/</a></p>

<p>Keep in mind if you are using a Self Signed certificate on an internal Jenkin Server you'll need to turn off certificate validation <strong>OR</strong> get the certificate from the server and add it to the HTTP request</p>

<p><a href="http://docs.python-requests.org/en/master/user/advanced/" rel="nofollow">http://docs.python-requests.org/en/master/user/advanced/</a></p>

python authentication jenkins