NOTE: you must be logged in to your GitHub account to create a personal access token
-
Once logged in to your GitHub account, go to https://github.com/settings/personal-access-tokens or
- Click on your profile picture in the top right
- Select "Settings" from the dropdown menu
- At the bottom the left navigation pane, select Developer settings
- Select Personal access tokens and then Fine-grained tokens
-
Click on Generate new Token
- You will have to authenticate with your GitHub account once more
-
Provide a Name for the token, though it is not used by the api, it is useful though and recommended as the name of the token if using my GitHub Pusher app.
-
Give it a description
- The default expiration is 30 days, but you can choose a longer expiration or one that never expires.
Here, you specify which repositories that you want the token to have access to. This can be Public repositories, All Repositories or Only selected repositories
- I recommend selecting Only select repositories and limit the vulnerability of the token to access all or more than the repositories that you want the token to have access to.
Each repository selected for the token will be granted the same permissions.
- Click on + Add Permissions
- **choose Contents: Read and write
- The Metadata permissions is required and added by default
- Click on Generate token
- You will be asked to confirm that you want to generate the token so confirm that the information is correct and click on Geenerate token
- Once it has been generated you need to copy the token and save it somewhere safe until you need to use it because you will not be able to see it again.
NOTE At any time you can go back to this settings view and delete the token or regenerate the token and alter the expiration date.
You can use my TokenChecker app to test the validity of the token with respect to the owner and the specific repository
You can download the zipped file from this repository (TokenChecker.zip)
Or you can download the source code and build it yourself. TokenChecker app folder
This will verify that the repository is accessible and if so, will list all files initially in the default branch,
If there is more than one branch, you will be able to select another branch and see the files in that branch,