Forum Academy Marketplace Showcase Pricing Features

Problem with context.keys

Hi all,

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.


The log outputs ‘undefined’

I also have tried doing console.log(context.keys[‘access-key’]);
Anyone that can help me?

Thanks!

Console log is client side and the context keys is ‘undefined’ because the browser is not allowed to see it.

var Authorization = context.keys[“API Key”];

Define API Key in the Shared tab as Secret

Hi thanks for the quick response,

is this the way you mean it to be?
image

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?

Kind regards

You can not expose context keys with console log.

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.

1 Like

Learned something new! Did not know this :hugs:

1 Like

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.

1 Like