Set token non-interactively
Closed this issue · 3 comments
I am installing packages from GitHub in a docker container and running into rate limiting. How does one set token non-interactively from an environment variable?
I am thinking of something like this..
gitcreds_set(url = "https://github.com", token = Sys.getenv("TOKEN"))
Perhaps, I am missing something.
Do want to use a credential helper on GitHub? Or what are you "setting" the token for?
I am installing packages from github using remotes::install_github()
and I got this error:
HTTP error 403.
API rate limit exceeded for XXX.XXX.XX.XX. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
Rate limit remaining: 0/60
Rate limit reset at: 2024-08-28 15:41:38 UTC
To increase your GitHub API rate limit
- Use `usethis::create_github_token()` to create a Personal Access Token.
Use `gitcreds::gitcreds_set()` to add the token.
which is how I came across gitcreds::gitcreds_set()
.
But, I just noticed that remotes::install_github()
has an argument called auth_token
. Perhaps that's what I need.
remotes will pick up the GITHUB_PAT
environment variable, no need to use a credential helper.
Or even better, use https://github.com/r-lib/actions/tree/v2-branch/setup-r-dependencies, look at the suggested workflows here: https://github.com/r-lib/actions/tree/v2-branch/examples