I’m quite new to plugin development in bubble so bare with me. I’m trying to write a s3 connection plugin where I need an access key and a secret key. I have defined these in the additional keys section. When testing my plugin I have defined both these fields in the plugins tab and have put these keys in both the access_key field and the access_key (dev) field.
How ever when trying to access these keys I stumble upon an undefined value.
Even without console logging it, it’s still missing. Is this because of the fact that I’m trying to access this key in an element action? Should this be done in an independant action that happens server side?
You can use console.log with server side too. But you need to go in Bubble Logs to see the result.
And yes, this will be exposed in Bubble logs at this moment.
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.