Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use environmental variables in password #10

Open
AGSCL opened this issue Aug 9, 2023 · 4 comments
Open

Use environmental variables in password #10

AGSCL opened this issue Aug 9, 2023 · 4 comments

Comments

@AGSCL
Copy link

AGSCL commented Aug 9, 2023

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

@mattwarkentin
Copy link
Owner

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.

@AGSCL
Copy link
Author

AGSCL commented Aug 10, 2023

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
Copy link
Author

AGSCL commented Aug 20, 2023

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')`

@natbprice
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants