我使用的是RStudio + Github,并一直遵循下面的说明:https://happygitwithr.com/https-pat.html
它工作得很好,只是在几个小时内PAT不再工作了,我被提示输入用户名/密码。我回去生成一个新的PAT,然后重复。这是我用的密码。
> usethis::create_github_token()
• Call `gitcreds::gitcreds_set()` to register this token in the local Git credential store
It is also a great idea to store this token in any password-management software that you use
✔ Opening URL 'https://github.com/settings/tokens/new?scopes=repo,user,gist,workflow&description=DESCRIBE THE TOKEN\'S USE CASE'
> usethis::create_github_token()
• Call `gitcreds::gitcreds_set()` to register this token in the local Git credential store
It is also a great idea to store this token in any password-management software that you use
✔ Opening URL 'https://github.com/settings/tokens/new?scopes=repo,user,gist,workflow&description=DESCRIBE THE TOKEN\'S USE CASE'
> gitcreds::gitcreds_set()
? Enter password or token: <token>
-> Adding new credentials...
-> Removing credetials from cache...
-> Done.我还提出了以下几点:
git config --global credential.helper 'cache --timeout=10000000'发布于 2022-08-24 20:34:17
PAT可以作为环境变量存储,因此在key=value文件中分配~/.Renviron是一种非常可能的解决方案。
另一种方法是通过~/.Rprofile通过Sys.setenv(key="value")显式地注入它。
您可以在任何R会话中通过
> v <- Sys.getenv()
> "GITHUB_PAT" %in% names(v)
[1] TRUE
> 当您创建一个PAT (在GitHub UI中)时,您可以给它显式的生存期。我很高兴地在这个星期重复使用它,这是我一年前为一个特殊的脚本需求创建的。
https://stackoverflow.com/questions/73437388
复制相似问题