Move API key from one environment to another

I’m developing a client side customization that leverages Functions, and to utilize this, I will need to create an API key and hard code it into the customization.
As far as I have seen, there is no way (hope I’m dead wrong on it) that one can move an API key from one environment to another.
In my mind, then the problem becomes changing the customization itself after being moved into a different environment to reference the new API key in the different environment.
Any thoughts?

Don’t hard code the API in the customization.

Store it somewhere (Company Config table perhaps) then look it up in your Customization.

Also you can’t copy an API form environment to environment (easily)

2 Likes

Interesting, but same problem exists, yes?

Well the moving of the API problem does exist, but if you store the API Key (for internal use) in say Company Config you can just update it there and not touch the code.

2 Likes

That’s a good plan, thanks

Also once you have it setup then you don’t ever have to change it in either system since it isn’t directly attached to the customization.

Insert disclaimers here about security practice and scope and blah blah blah

So you’re just saying extend the company config table to store it, then look it up in the customization, yes?

Correct, we do this with several “keys” that we need available (not API keys necessarely but file paths and crap like that)
Make a customization in Company Config add the custom fields and controls etc so that people can update them

Then use a BAQView or BOReader or CompanyAdapter to read them back out as needed.

1 Like

Sweet I like it!

1 Like

I’m curious if anyone has been able to use this methodology to solve the API key problem across multiple environments. I am trying to implement the erp-function widget and it is interpreting my field reference as a string literal. I have verified that I am successfully pulling the key from a rest lookup into a dataview that I’ve named FunctionKey which comes from a UD table. When I use {FunctionKey.ShortChar01} in the API key parameter, I get and error saying that ‘Invalid API Key {FunctionKey.ShortChar01}’. I’ve also tried removing the curly braces and putting the whole thing in quotes but to no avail.

Welcome Mark!

Have you tried leaving the API-Key blank?

Well go figure! The * that typically indicates a required field does not actually mean that in this case. Thank you Mark. Greatly appreciated!

Sorry to add to this dead thread, but when I refresh our pilot environment with production data, can the same API key that was generated in the production environment be used to access the pilot environment after it is copied? If not possible, is there a way to update the information in SQL on the pilot server so the generated key is retained/known?

Yes. I had separate, but when I copied, I had to start using the production one.

1 Like

@klincecum That’s exactly what I was looking for, thanks for confirming!