Query git credentials from R
Query git credentials from R
(Re)use the same credentials in command line git, R and the RStudio IDE., etc. Users can set their GitHub token once and use it everywhere.
Typically more secure than storing passwords and tokens in .Renviron
files.
gitcreds has a cache that makes credential lookup very fast.
gitcreds supports multiple users and multiple hosts, including Enterprise GitHub installations.
If git or git credential helpers are not available, e.g. typically on a Linux server, or a CI, then gitcreds can fall back to use environment variables, and it still supports multiple users and hosts.
gitcreds is typically used upstream, in R packages that need to authenticate to git or GitHub. End users of these packages might still find it useful to call gitcreds directly, to set up their credentials, or check that they have been set up correctly.
You can also use gitcreds in an R script. In this case you are both the end user and the upstream developer.
Use gitcreds_get()
to check your GitHub or other git credentials. It returns a named list, with a password
entry. The password is not printed by default:
#> <gitcreds>
#> protocol: https
#> host : github.com
#> username: gaborcsardi
#> password: <-- hidden -->
Use gitcreds_set()
to add new credentials, or replace existing ones. It always asks you before replacing existing credentials:
#> -> Your current credentials for 'https://github.com':
#>
#> protocol: https
#> host : github.com
#> username: gaborcsardi
#> password: <-- hidden -->
#>
#> -> What would you like to do?
#>
#> 1: Keep these credentials
#> 2: Replace these credentials
#> 3: See the password / token
#>
#> Selection: 2
#>
#> ? Enter new password or token: secret
#> -> Removing current credentials...
#> -> Adding new credentials...
#> -> Removing credetials from cache...
#> -> Done.
Use gitcreds_delete()
to delete credentials. It always asks you before actually deleting any credentials:
#> -> Your current credentials for 'https://github.com':
#>
#> protocol: https
#> host : github.com
#> username: token
#> password: <-- hidden -->
#>
#> -> What would you like to do?
#>
#> 1: Keep these credentials
#> 2: Delete these credentials
#> 3: See the password / token
#>
#> Selection: 2
#> -> Removing current credentials...
#> -> Removing credetials from cache...
#> -> Done.
MIT © RStudio