【问题标题】:Ask user crendentials when running R in Terminal在终端中运行 R 时询问用户凭据
【发布时间】:2020-01-09 02:53:36
【问题描述】:

我正在从Terminal(不是 RStudio)运行R script,有时我需要用户编写用户名和密码才能访问 API。为此,我使用了以下代码的非安全方法:

cat('Write username: ')
username<-readLines("stdin", n=1)
cat('Write password: ')
password<-readLines("stdin", n=1)

我已经看到在 RStudio 中有一个很好的实现,使用 rstudioapi 包和 askForPassword 函数,但是由于我是从 Termianl 运行我的脚本,我想知道是否有任何替代或更安全的方法来请求这个信息

【问题讨论】:

标签: r terminal credentials password-protection


【解决方案1】:

getPass 是您的最佳解决方案。

它支持 RStudio 并在缺少时回退到 tcltk 和其他后端。

password &lt;- getPass::getPass() 是您的电话。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-02
    • 2022-10-15
    • 1970-01-01
    • 2011-08-23
    • 2017-11-04
    • 1970-01-01
    • 2014-09-02
    相关资源
    最近更新 更多