1

I'm creating a vignette in RMarkdown for a package that requires a secret API key. I'm including the key as an environment variable, and then using this key as an argument; but when I check the package build, I get a Warning because it can't read my environment variable.

If I pass in the key directly into the function, I don't get the Warning.

Here is the Warning:

Error: processing vignette '' failed with diagnostics:
second argument must be a list
Execution halted

My code looks

 apikey = Sys.getenv('key')

 house_enacted_115 <- getBills(apikey,"115","house","enacted",1,20)
NadineK
  • 131
  • 1
  • 2
  • 9
  • What does your code look like? – MrFlick Nov 16 '17 at 15:52
  • I just added the code to the question – NadineK Nov 16 '17 at 15:59
  • How are you creating the environment variable? – Eumenedies Nov 16 '17 at 16:46
  • 8
    Don't do this. You'd have to give out the key insecurely at some point. Cache the data, `eval=FALSE` the code chunks that grab data from the API in the vignette, `echo=FALSE` the ones that actually read the cached data. You don't need the vignettes to exercise the API, just explain the API to the users. Similarly, have your tests `skip_on_cran()` and `\dontrun{}` your examples. Then securely use your API keys on Travis and note the Travis link in your CRAN submission so they can validate regular testing occurs. – hrbrmstr Nov 16 '17 at 16:52
  • (I may have made an API pkg or three ;-) – hrbrmstr Nov 16 '17 at 16:53
  • I have a similar issue I am writing a vignette for an r package but the function needs an api key? – Shivam Oct 13 '18 at 10:24

0 Answers0