【发布时间】:2021-09-01 10:10:25
【问题描述】:
我正在尝试使用 GitHub Actions 通过 R 脚本使用 OAuth 2.0 令牌查询 GitHub API。当我运行代码时,它在我的本地计算机上运行良好,其中会弹出一个浏览器窗口,指示“正在等待浏览器中的身份验证...”,我可以手动关闭它。通过 GitHub Actions 运行时,工作流会挂在“正在等待浏览器中的身份验证...”,因为它位于远程计算机上。
我正在使用带有 httr 库的自定义 R 脚本。 API 凭据存储为我尝试查询的存储库的机密。
library(httr)
gh_key <- Sys.getenv('GH_KEY')
gh_secret <- Sys.getenv('GH_SECRET')
# setup app credentials
myapp <- oauth_app(appname = "data-in-r",
key = gh_key,
secret = gh_secret)
# get oauth credentials
github_token <- oauth2.0_token(oauth_endpoints('github'), app = myapp, cache = F)
# use api
gtoken <- config(token = github_token)
# get list of remote files in data folder
req <- GET("https://api.github.com/repos/tbep-tech/piney-point/contents/data", gtoken)
当脚本通过 GitHub Actions 运行时,如下所示,我不得不手动取消工作流,因为它在浏览器步骤被挂起。
是否有跳过浏览器步骤以便在 GitHub Actions 上运行的解决方法?有问题的仓库是here。
【问题讨论】:
标签: r oauth-2.0 github-actions httr