Jenkins GitHub OAuth Plugin (GitHub Authentication plugin)
Why: Use GitHub user credentials to administer Jenkins instance, using GitHub OAuth Application.
Plug-in details: https://plugins.jenkins.io/github-oauth
Configuration (Github): Step1: https://github.com → Settings → Developer Settings → New OAuth Apps → New OAuth App.

- Application Name: Jenkins
- HomePageURL: Your Jenkins landing page URL, for me it is https://jenkis..ninja
- Application Description: Whatever you like
- Authorization callback:
<JENKINS_URL>:<JENKINS_PORT>/securityRealm/finishLoginplease make sure your spellings are correct
Add your application

Step 2: Configuration (Jenkins)

- Enable security checkbox
- Access Control checkbox
- Github Authentication plugin
- Github Web URI: https://github.com or your own Github server instance
- Client Id: which will you get from Github
- Client Secret: Secret key that you will get from GitHub while Adding Jenkins as application
- OAuth Scope(s): read:org,user:email,repo
Then Authorization:
- Matrix-based Security: checkbox check as checked-in screenshot
For more details please read https://plugins.jenkins.io/github-oauth/
Answer from Dupinder Singh on Stack OverflowConfiguring Jenkins with GitHub (Authorization) - Stack Overflow
How to Configure GitHub App Authentication in Jenkins Pipeline Script for Secure Repository Access - Stack Overflow
Github Application Credentials
Using GitHub app authentication for our Jenkins
Videos
Check first if you have the github-oauth Jenkins plugin installed, as described in "Use the Jenkins OAuth plug-in to securely pull from GitHub", from Walker Rowe.
That would allow to register your Jenkins server as an application which can then access GitHub resources:

Another approach is to take advantage of the GitHub App authentication support
It is released in April 2020 with GitHub Branch Source 2.7.0-beta1 which is available in the Jenkins experimental update center.
Why authenticate as a GitHub app?
- Larger rate limits - The rate limit for a GitHub app scales with your organization size, whereas a user based token has a limit of 5000 regardless of how many repositories you have.
- User-independent authentication - Each GitHub app has its own user-independent authentication.
No more need for 'bot' users or figuring out who should be the owner of 2FA or OAuth tokens.- Improved security and tighter permissions - GitHub Apps offer much finer-grained permissions compared to a service user and its personal access tokens.
This lets the Jenkins GitHub app require a much smaller set of privileges to run properly.- Access to GitHub Checks API - GitHub Apps can access the the GitHub Checks API to create check runs and check suites from Jenkins jobs and provide detailed feedback on commits as well as code annotation

And:
In addition to usage of GitHub App authentication for Multi-Branch Pipeline, you can also use app authentication directly in your Pipelines.
You can access the Bearer token for the GitHub API by just loading a 'Username/Password' credential as usual, the plugin will handle authenticating with GitHub in the background.
If you're using the Branch Source Plugin with GitHub App authentication, you don't have a token at hand in Jenkins. But the credentials provider is smart enough to give you an access token derived from the App with just the same withCredentials step:
withCredentials([usernamePassword(credentialsId: 'id-of-your-github-app-credentials',
usernameVariable: 'GITHUB_APP',
passwordVariable: 'GITHUB_ACCESS_TOKEN')]) {
// Use the access token via $GITHUB_ACCESS_TOKEN here
}
Note that you have to use usernamePassword as type, even if your credentials referenced by ID are of type GitHub App.
See official Jenkins blog post n GitHub App authentication for further info.
You can define a password parameter in jenkins job and the same can be used in your github script.
Ex : You can define a password variable either as a build param or a new password variable using inject global passwords ( provide u have this plugin)
The same password can be used in script which use api
Below command uses github api call and will list down repos in your organization
Make sure <your_organization_name_HERE> is replaced with your organization name
curl --silent -q -H "Authorization: token ${github_api_pwd}" https://api.github.com/orgs/<your_organization_name_HERE>/repos
Similarly you can get other information using other api's