how do you access a jenkins api which uses Github OAuth using CURL

You should just use a Jenkins API token. This is configurable per user. See $JENKINS_URL/me

This will allow your scripted client to access Jenkins regardless of whatever authentication strategy is being used.


I'm not sure if you ever got to the bottom of this, but after trying several routes I finally got a scripted build using Github OAuth on Jenkins. The trick is that the API token is not one for GitHub but rather one from Jenkins.

For my setup I have a machine user on github, I logged in normally via the web with that user, then clicked on the username in the upper right corner. From there I clicked "Configure" on the left-hand menu, and finally "Show API Token" in the main content area.

Once I had that I could run:

curl --user <username>:<api_token> https://jenkins-server/user/<username>/api/json/?pretty=true

More information.