Problem with context.keys

I just wanted to add on to/clarify on this topic.

  • private shared keys are hidden from the client. They are not accessible from context.keys[your_private_key] inside a plugin function. This includes any clien-side JS including console.log or any other JS function. This is to avoid exposing sensitive private keys to your client.
  • public shared keys are visible from the client. They are accessible from context.keys[your_public_key], can be logged from console.log and used in client-side elements and are accessible from the client. Do not store sensitive API keys in here.

There is one important development quirk when working with shared keys. If you run console.log(context.keys)you will see all public keys that you have created only if those keys have a value set inside the page editor. You will not see the names of keys with blank values inside the context.keys, you must set them first for the key name to become visible.

I mention this because I ran into this issue of not seeing my public keys. I read this post and it wasn’t clear to me that I could even access public keys from client-side.

2 Likes