Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set token non-interactively #62

Closed
royfrancis opened this issue Aug 28, 2024 · 3 comments
Closed

Set token non-interactively #62

royfrancis opened this issue Aug 28, 2024 · 3 comments

Comments

@royfrancis
Copy link

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.

@gaborcsardi
Copy link
Member

Do want to use a credential helper on GitHub? Or what are you "setting" the token for?

@royfrancis
Copy link
Author

royfrancis commented Aug 28, 2024

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.

@gaborcsardi
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants