Secrets / environment variables

Are there any plans for a way to include secrets (e.g. API keys) that are private to the user executing the notebook, even if the notebook itself is public? RunKit allows environment variables (https://discuss.runkit.com/t/using-environment-variables-with-tonic/21) which seems like a fairly elegant solution.

1 Like

Couldnā€™t that just be any cell? If someone types an API key into their local copy of a notebook, it doesnā€™t get published.

Alternately, you could make a little view which saves a variable typed into it to localStorage or whatever.

This feature doesnā€™t necessarily require any explicit support from Observable.

1 Like

Yep, what Jacob said - and to make it concrete & reusable, hereā€™s a notebook that you can import from and quickly start storing environment/secrets:

4 Likes

Not sure how much it matters, but note that if you want this to work in Safari or Edge you canā€™t use spread syntax in object literals.

So ā€¦

  const input = text({
    value,
    ...options
  });

ā€¦ throws an error.

Wow, thanks for the thoughtful replies. I love the back and forth between questions <> notebooks. Iā€™m not sure, but I think there might still be good reasons to want secrets in a place well-defined by the notebook runtime/environment. Need to play with this mechanism for a while now :slight_smile:

Not to revive an old topic. But would be great if Tomā€™s Secret notebook was moved to one of the main observable collections - maybe Techniques ? Not that hard to find with google search - but didnā€™t know it existed - and between all my cloud services out there, got a lot of secrets in the closet : - is a great import if one knew it existed. @tom