title: Jenkins json REST api with CORS request using jQuery
body: <p>I'm trying to use the Jenkins json API and cannot get the authentication to work.</p>
  
  <p>setup:</p>
  
  <ul>
  <li>Jenkins security: <code>Jenkin’s own user database</code></li>
  <li>access: <code>Matrix-gebaseerde beveiliging</code></li>
  <li>CORS via <a href="https://wiki.jenkins-ci.org/display/JENKINS/Cors+Filter+Plugin" rel="nofollow">Jenkins CORS plugin</a></li>
  <li>using username/api token of a registered user</li>
  </ul>
  
  <p>tried:</p>
  
  <pre><code>var username = "username";
  var apiToken = "apiToken";
  
  // username / api-token on url (basic authentication)
  $.ajax({
    url: "http://"+username+":"+apiToken+"@host:port/job/test/api/json",
    method: "GET"
  });
  
  // username / api-token supplied using jQuery's username/password properties
  $.ajax({
    url: "http://host:port/job/test/api/json",
    method: "GET",
    username: username,
    password: apiToken
  });
  
  // username / api-token by setting "Authorization" header directly
  $.ajax({
    url: "http://host:port/job/test/api/json",
    method: "GET",
    headers: {
        "Authorization": "Basic " + btoa(username + ":" + apiToken)
    }
  });
  </code></pre>
  
  <p>All these attempts result in the same result:
  <strong>response: 403 Forbidden</strong></p>