How to get https apij's key

Hello,

In configure mode, I can use following command to get the key

show service https api keys id localweb key

How could a C program running in vyos get this key?

  • The proper way would obviously be to connect to the /retrieve API endpoint, but in your case it’s a catch 22 as to be able to connect to the API you’ll need the key.

  • You can also find the key in your config.boot file. This method has some drawbacks where the key in the file is the boot time key and not the live key, and it’s not API stable (meaning the syntax might change which will break your program).

  • One last way is executing the python VyOS UI directly similar to what the script-template bash helper does.

The api server stores basic information in a json file:
/etc/vyos/http-api.conf
That format is unlikely to change; it does not change with CLI syntax migration, at least.

Thanks!
At first, I read the key from boot config file(/config/config.boot), however I found the config.boot will not change until I exec save command.
I checked the /etc/vyos/http-api.conf will change as soon as I exec commit command.