title: how do you access a jenkins api which uses Github OAuth using CURL
body: <p>I have a jenkins server using the Github OAuth plugin and authorized in the "Authorized applications" section of github, it works fine from my browser, i can access to the jenkins server as long as i'm authenticated with github.</p>
  
  <p>Is there a way to access to the jenkins server api using oauth credentials/token from CURL or a ruby client? </p>
  
  <p>I've generated a token in <a href="https://github.com/settings/applications" rel="noreferrer">https://github.com/settings/applications</a> -> Personal access tokens -> Generate new token (there is no option to scope it to a third party application)</p>
  
  <p>that token works fine to access github :</p>
  
  <p><code>
      curl -H "Authorization: token cfbcff42e6a8a52a1076dd9fcxxxxxxxxxxxxxxx" https://api.github.com/user
  </code></p>
  
  <p>however, that token is not valid for jenkins-server:</p>
  
  <p><code>
      curl -H "Authorization: token cfbcff42e6a8a52a1076dd9fcxxxxxxxxxxxxxxx"        https://jenkins-server/user/restebanez/api/json/\?pretty\=true
  </code></p>
  
  <p>It generates this error:</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;&lt;meta http-equiv='refresh' content='1;url=/securityRealm/commenceLogin?from=%2Fuser%2Frestebanez%2Fapi%2Fjson%2F%3Fpretty%3Dtrue'/&gt;&lt;script&gt;window.location.replace('/securityRealm/commenceLogin?from=%2Fuser%2Frestebanez%2Fapi%2Fjson%2F%3Fpretty%3Dtrue');&lt;/script&gt;&lt;/head&gt;&lt;body style='background-color:white; color:white;'&gt;
  
  
      Authentication required
  &lt;!--
  You are authenticated as: anonymous
  Groups that you are in:
  
                          Permission you need to have (but didn't): hudson.model.Hudson.Read
   ... which is implied by: hudson.security.Permission.GenericRead
   ... which is implied by: hudson.model.Hudson.Administer
  --&gt;
  
  &lt;/body&gt;&lt;/html&gt;     
  </code></pre>
  
  <p>```</p>
  
  <p>the jenkins server has installed GitHub API Plugin 1.58 and Github Authentication plugin 0.19</p>
  
  <p>I'm probably missing some fundamentals of oauth b/c i have googled this for a while and i haven't found anything</p>