fidelius icon indicating copy to clipboard operation
fidelius copied to clipboard

Use environmental variables in password

Open AGSCL opened this issue 1 year ago • 4 comments

Is it possible to use 'r Sys.getenv("CANVASPASS")' or "r as.character(read.table('H:/Mi unidad/Curso_UDP/pass_canvas.txt', quote='"', comment.char=''))"' ` in password YAML?

output: fidelius::html_password_protected: style: button_text: "Ingresar clave" password: 'r Sys.getenv("CANVASPASS")' preview: false hint: "" bundle: true output_format: rmarkdown::html_document: toc: true # table of content true toc_depth: 5 # upto three depths of headings (specified by #, ## and ###) toc_float: true

AGSCL avatar Aug 09 '23 20:08 AGSCL

Hi @AGSCL,

I think this should be possible with something like:

---
output:
  fidelius::html_password_protected:
    password: `r Sys.getenv('CANVASPASS')`
    output_format: rmarkdown::html_document
---

Let me know if this does not work for you.

mattwarkentin avatar Aug 10 '23 15:08 mattwarkentin

Hi,

I get the following error

Error in yaml::yaml.load(..., eval.expr = TRUE) : 

  Scanner error: while scanning for the next token at line 3, column 15 found character that cannot start any token at line 3, column 15

  |  
 

<br class="Apple-interchange-newline"><!--EndFragment-->
</body>
</html>

AGSCL avatar Aug 10 '23 16:08 AGSCL

If I replace it with "`r Sys.getenv('Key1')`", it looks that it don't evaluate the code, so If I put the following password, it work: `r Sys.getenv('Key1')`

AGSCL avatar Aug 20 '23 20:08 AGSCL

I was encountering the same error in yaml::yaml.load(..., eva.expr = TRUE). I found the !expr tag as described in yaml::yaml.load() to work. For example:

output: 
  fidelius::html_password_protected:
    password: !expr as.character(1+1)

natbprice avatar Nov 01 '23 12:11 natbprice