# Franklin + API keys

**URL:** https://discourse.julialang.org/t/franklin-api-keys/36321
**Category:** Web Stack
**Tags:** question
**Created:** [March 21, 2020, 10:08pm UTC](https://discourse.julialang.org/t/franklin-api-keys/36321 "2020-03-21T22:08:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)
#### Post date: [March 21, 2020, 10:08pm UTC](https://discourse.julialang.org/t/franklin-api-keys/36321/1 "2020-03-21T22:08:03Z")

</div>

I am trying to build a website that just displays some sexy PlotlyJS plots using Franklin. So far, so good! But part of my code will rely on [GitHub - micahjsmith/FredData.jl: Pull data from Federal Reserve Economic Data (FRED) directly into Julia](https://github.com/micahjsmith/FredData.jl), which requires an API key. When my Franklin site is deployed on GitHub, how can I have it access the key (without just saving the key in the public repo of course)?

That README does state that I can:  
“Populate the environment variable `FRED_API_KEY` such that it remains across sessions.”

I am guessing that I can use this with GitHub secrets, but not quite sure what that would look like or entail. Any help is appreciated.

---

<div class="post-metadata">

### Author: ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)
#### Post date: [March 22, 2020, 1:18am UTC](https://discourse.julialang.org/t/franklin-api-keys/36321/2 "2020-03-22T01:18:21Z")

</div>

Not sure if you are deploying this on a Windows or Linux machine…or something else.

If it’s windows you should be able to search for “environment” in the start menu then define the FRED\_API\_KEY with the correct value.

On linux if you start the process with a bash script to can also set an environment variable with:

```julia
export FRED_API_KEY="blah blah blah"

```

Or possibly add that to one of the startup scripts for the user.

With either platform the value of the key is not defined in the source at all. You just need to document in the install/deployment process that the FRED\_API\_KEY must be defined as an environment variable for the application to work correctly.

---

<div class="post-metadata">

### Author: ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)
#### Post date: [March 22, 2020, 2:00am UTC](https://discourse.julialang.org/t/franklin-api-keys/36321/3 "2020-03-22T02:00:44Z")

</div>

Sorry, I mean for GitHub deployment. Like GitHub actions. Locally, I have it defined. But when GitHub deploys the site it also needs to evaluate the code, thus it also needs the key. Right?

---

<div class="post-metadata">

### Author: ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)
#### Post date: [March 22, 2020, 8:05am UTC](https://discourse.julialang.org/t/franklin-api-keys/36321/4 "2020-03-22T08:05:12Z")

</div>

You should be able to add it as a key on GitHub with the same process as for the DEPLOY\_KEY (see [https://github.com/tlienart/Franklin.jl/issues/390](https://github.com/tlienart/Franklin.jl/issues/390)) and then just write it to ~./fredconfig with the GitHub action.

Another way would be to access the key from the julia -e block but I’m not sure how that would work (I’m not very confident with how GitHub actions work yet)

I’ll try the first way in a bit and report if I get lucky

---

<div class="post-metadata">

### Author: ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)
#### Post date: [March 22, 2020, 10:03am UTC](https://discourse.julialang.org/t/franklin-api-keys/36321/5 "2020-03-22T10:03:19Z")

</div>

Ok this works: [Franklin Sandbox](https://tlienart.github.io/fred/)

The source repo: [GitHub - tlienart/fred](https://github.com/tlienart/fred)

in terms of the github action workflow, you need to do the same stuff as pointed out in the link in my previous message (that’s for the Franklin github action) then you just need to add a new secret `FRED_API_KEY` on GitHub which is written to `~/.freddatarc` in the action (see [fred/deploy.yml at 977bc256228e77e97b212dc8af3a214f11804c90 · tlienart/fred · GitHub](https://github.com/tlienart/fred/blob/977bc256228e77e97b212dc8af3a214f11804c90/.github/workflows/deploy.yml#L37))

Hope this helps!

PS: you may have to look up how to avoid showing “API key loaded” with FredData but that seems like a minor nuisance that should be easy to fix 😄

---

<div class="post-metadata">

### Author: ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)
#### Post date: [March 22, 2020, 7:35pm UTC](https://discourse.julialang.org/t/franklin-api-keys/36321/6 "2020-03-22T19:35:40Z")

</div>

Above and beyond the call of duty. Thanks a bunch! Exactly what I was looking for
