【问题标题】:authenticating to github from Rstudio从 Rstudio 向 github 进行身份验证
【发布时间】:2021-09-23 19:23:17
【问题描述】:

[环境:RStudio 版本 1.4.1106,R 版本 4.0.2]

由于 github 不允许通过用户名/密码进行身份验证,我在从 RStudio 推送项目更新时遇到了问题。

我设置了一个 github PAT 并将其安装在 .renviron

GITHUB_PAT=ghp.....

检查,使用usethis::sitrep(),看起来一切正常,AFAICS:说“发现个人访问令牌”

> usethis::git_sitrep()
Git config (global)
* Name: 'Michael Friendly'
* Email: 'friendly@yorku.ca'
* Vaccinated: TRUE
i Defaulting to 'https' Git protocol
* Default Git protocol: 'https'
GitHub
* Default GitHub host: 'https://github.com'
* Personal access token for 'https://github.com': '<discovered>'
* GitHub user: 'friendly'
* Token scopes: 'gist, repo, user, workflow'
* Email(s): 'friendly@yorku.ca (primary)', 'michael.friendly@gmail.com'
Git repo for current project
* Active usethis project: 'C:/R/Projects/HistDataVis'
* Default branch: 'main'
* Current local branch -> remote tracking branch:
  'main' -> 'origin/main'
GitHub remote configuration
* Type = 'ours'
* Host = 'https://github.com'
* Config supports a pull request = TRUE
* origin = 'friendly/HistDataVis' (can push)
* upstream = <not configured>
* Desc = 'origin' is both the source and primary repo.
  
  Read more about the GitHub remote configurations that usethis supports at:
  'https://happygitwithr.com/common-remote-setups.html'
> 

然而,当我尝试推送到 github 时,系统会提示我一个用户 ID/密码对话框,但由于 github 拒绝密码身份验证而失败。

进一步检查:GITHUB_PAT 好像没问题,

> Sys.getenv("GITHUB_PAT")
[1] "ghp_T..."
> 

可能出了什么问题?否则我该如何测试?我该怎么做才能解决这个问题?

【问题讨论】:

标签: authentication github rstudio


【解决方案1】:

我还没有开始在全球范围内这样做,但这可以在逐个回购的基础上进行

git remote set-url origin git@github.com:username/repo.git

在项目的 .git 目录中。 (一点也不明显。)

【讨论】:

  • 谢谢。这对我有用,虽然 为什么 尚不清楚。它还解释了为什么身份验证对我的一些存储库有效,而另一些则无效。
猜你喜欢
  • 1970-01-01
  • 2017-11-30
  • 2022-07-11
  • 2021-12-23
  • 2013-08-03
  • 2021-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多