I am trying to transition from the GitHub Personal Access Tokens
classic version to the currently beta version fine-grained tokens
. My issue is the token expiration max age is 1 year, whereas before the classic tokens could be set to not have any expiration. I know the simplest solution is just use the classic tokens, but if I've learned anything from GitHub's beta programs is that they will deprecate the previous option eventually. The fine-grained tokens
are also appealing given they limit access to 1+ specific repositories.
I understand the reasons behind the expiration but am having an issue reconciling how to handle it. My issue is I have python packages hosted on GitHub using private repositories. I have a requirements.txt
using the token to install the package(s) in the private repository(s) in multiple applications/scripts being hosted on the cloud or ran locally on multiple machines. If I only had one repository it would be a simple update, but there are many programs consuming these private packages. So, when the token(s) inevitably expires (max age is currently a year) I will then need to update the requirements.txt
for all repositories that use the private repository package(s).
I realize I could store the token in a separate file and reference the token. However, this doesn't seem like a proper approach given the syntax appears so convoluted.
-e git+https://github.com/USERNAME/REPOSITORY.git@TAG#egg=PACKAGE_NAME&
subdirectory=PACKAGE_DIRECTORY&oauth_token=$(cat PATH/TO/FILE.TXT)
This solution also doesn't solve the case where I have an CD GitHub Action
that deploys an application to AWS that needs to install the private repositories' packages. I would need to store the fine-grained token(s)
as a Secret for the repository to be used in the GitHub Action
. Then when the token inevitably updates I will have to go to every repository and update it.
I created the fine-grained access
tokens and began using them but ran into the issues described above.