Best practice to store api keys

Hi,

Its the first time i have used a external api.

I am using a external api that has a clientid(never changes), apikey(need to be changed every 90 days), email(never changes) and bearer token (changes every 30 mins). To get a bearer token and api key change this can be done by the api.

I'm currently storing them in environment variables. Is this best practice? Can i update the environment variables without changing them in the settings tab? Should i be saving them somewere else.

Projects on node if that makes any difference.

Any help would be greatly appreciated :grinning:

Cheers,

Environment variables are indeed best practice for static keys, rotating ones might be best stored in the database

Dynamically setting environment variables is not natively supported by Wappler

2 Likes

Thanks @Apple

I have a custom node module to change the values of ENV variables for the server session.

I can upload as Npm for you if it would be useful.

1 Like

Thanks, that would be perfect if you wouldn't mind.

I presume i can then add my start env values into wappler in the settings tab and then update the env as i need to?

Thanks

Thats exactly what it does,
It can change its value, return its current value or or declare a new variable for the remainder of the server session.

it would then default back to original settings value on server restart and all newly assigned values / variable are cleared.

30 mins.

1 Like

I will do a full post on using this when i have time

here is the interface

Simply enter the ENV variable name
As it is convention, the name is converted into upper case UNLESS you tick allow Mixed case.

enter the value you want to set it to

If the env variable is already declared it is changed
if not declared it is created
if no value is sent, the current value is returned

This example returns

{"Env1":"english"}
3 Likes
2 Likes

Thanks @Hyperbytes really do appreciate it :slight_smile:

Why not just store these in the database and update them when needed?