Answers: <p>You want the <a href="https://plugins.jenkins.io/credentials" rel="nofollow noreferrer">Credentials Plugin</a>.</p>
  
  <p>The administrator of the Jenkins instance can add the plugin, then add the credential (access token) that the job needs. Then, in the job, <a href="https://github.com/jenkinsci/credentials-plugin/blob/master/docs/user.adoc#using-credentials" rel="nofollow noreferrer">use the credential</a> as a variable.</p>
  
  <p>See the <a href="https://github.com/jenkinsci/credentials-plugin/blob/master/docs/user.adoc" rel="nofollow noreferrer">documentation</a> for more details.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-11-06T11:17:27.317Z
Answers: 2018-11-06T11:17:27.317Z
Answers: Bruce Becker
Body: <p>I have a Jenkins job <code>foo</code> that works perfectly well. It is authenticated with <code>jenkins_foo_user</code>. It is able to clone the repo and checkout the right branch.</p>
  
  <p>In my codebase, I have another script - <code>query_github.py</code> a script used to query Github API to get information such as commits and pull request. To be able to use this API I need an access token.</p>
  
  <p>I want to be able to use the jenkins user access token to authenticate and access the github credentials.</p>
  
  <p>How do I do this?</p>
  
  <p>Note: Using the Github Enterprise version</p>
  
Tags: <jenkins><git><jenkins-plugins><github><authentication>
Title: How to use Jenkins github user credentials to access github api in my script?
UserDisplayName: suprita shankar
ThreadText: # How to use Jenkins github user credentials to access github api in my script?
  
  (Asked by: username_0 on 2018-11-06)
  
  I have a Jenkins job `foo` that works perfectly well. It is authenticated with `jenkins_foo_user`. It is able to clone the repo and checkout the right branch.
  
  In my codebase, I have another script - `query_github.py` a script used to query Github API to get information such as commits and pull request. To be able to use this API I need an access token.
  
  I want to be able to use the jenkins user access token to authenticate and access the github credentials.
  
  How do I do this?
  
  Note: Using the Github Enterprise version
  
  **Tags:** jenkins, git, jenkins-plugins, github, authentication
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-06. Score: 0 | Accepted answer
  
  You want the [Credentials Plugin](https://plugins.jenkins.io/credentials).
  
  The administrator of the Jenkins instance can add the plugin, then add the credential (access token) that the job needs. Then, in the job, [use the credential](https://github.com/jenkinsci/credentials-plugin/blob/master/docs/user.adoc#using-credentials) as a variable.
  
  See the [documentation](https://github.com/jenkinsci/credentials-plugin/blob/master/docs/user.adoc) for more details.
  
  
  ---
  
  