[英]Can't get Github PAT to persist - RStudio & Ubuntu 20
I'm using RStudio + Github and have been following the instructions here: https://happygitwithr.com/https-pat.html
它工作得很好,除了在几个小时内 PAT 不再工作并且提示我输入用户名/密码。 我将 go 返回并生成新的 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'
PAT 可以存储为环境变量,因此~/.Renviron
文件中的key=value
分配是一个非常可能的解决方案。
另一个是通过Sys.setenv(key="value")
从~/.Rprofile
显式注入它。
您可以通过任何 R session 进行测试
> v <- Sys.getenv()
> "GITHUB_PAT" %in% names(v)
[1] TRUE
>
当您创建PAT
(在 GitHub UI 中)时,您可以为其指定明确的生命周期。 我很高兴地重新使用了一年前为特定脚本需求创建的本周。
我在 PopOS(在 Ubuntu 上运行)下遇到了同样的问题,除了我可以使用: gitcreds::gitcreds_set()
并重新提供现有的 PAT,因此问题是 PAT 的本地存储的持久性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.