Missing required environment variable: RC_API_SECRET_HOST when using Vault

Hi,
I followed an example from Robocorp and I’m pretty sure no error or tipo so far but it’s keeping asking me for : RC_API_SECRET_HOST when I’m starting the robot with the command “rcc run”

I saw RC_API_SECRET_HOST as URL to Robocorp Vault API in the documentation but as I’m in local environment and don’t need to access the cloud or store something in it.

Do I miss something here ?

Thanks for your feedback.

Traceback (most recent call last):
  File "D:\RobotFramework\tasks.py", line 9, in <module>
    secret = Vault().get_secret("credentials")
  File "C:\Users\albel\AppData\Local\robocorp\holotree\5a1fac3c5_9fcd2534\lib\site-packages\RPA\Robocorp\Vault.py", line 556, in get_secret
    return self.adapter.get_secret(secret_name)
  File "C:\Users\albel\AppData\Local\robocorp\holotree\5a1fac3c5_9fcd2534\lib\site-packages\RPA\Robocorp\Vault.py", line 532, in adapter
    self._adapter = self._adapter_factory()
  File "C:\Users\albel\AppData\Local\robocorp\holotree\5a1fac3c5_9fcd2534\lib\site-packages\RPA\Robocorp\Vault.py", line 546, in factory
    return adapter(*args, **kwargs)
  File "C:\Users\albel\AppData\Local\robocorp\holotree\5a1fac3c5_9fcd2534\lib\site-packages\RPA\Robocorp\Vault.py", line 211, in __init__
    self._host = required_env("RC_API_SECRET_HOST")
  File "C:\Users\albel\AppData\Local\robocorp\holotree\5a1fac3c5_9fcd2534\lib\site-packages\RPA\core\helpers.py", line 56, in required_env
    raise KeyError(f"Missing required environment variable: {name}")
KeyError: 'Missing required environment variable: RC_API_SECRET_HOST'

Error: exit status 1
1 Like

You need to set up local vault to use secrets.

Hi,

These were the steps I went through :

  • I created a vault.json file that look like in the tutorial :
  {
  "credentials": {
    "username": <myusername>,
    "password": <mypassword>
  }
 }

and put it in : "C:\\Users\\<myuser>\\vault.json"

then I created the env.json file under devdata folder that looks like this :

{
  "RPA_SECRET_MANAGER": "RPA.Robocorp.Vault.FileSecrets",
  "RPA_SECRET_FILE": "C:\\Users\\<myuser>\\vault.json"
}

And finally, I requested my credential in my tasks.py robot (Actually, I’m using full python implementation instead of robotframework script)

and it looks like this :

from RPA.Browser.Selenium import Selenium
from RPA.Robocorp.Vault import Vault
from robot.api import logger
lib = Selenium()

secret = Vault().get_secret("credentials")
username = secret["username"] 
password = secret["password"]

So, if I understood, all things are there except creating credentials in robocorp cloud. Something that I don’t want to do.

As I’m newbie, maybe there are things I didn’t catch up yet.

@arcondo.dasilva are you running in terminal with rcc run ? If yes, then you need to pass env.json as an argument for rcc

rcc run -e devdata\env.json

The VSCode Robocorp extension includes devdata env.json automatically if it exists, but when running in terminal you need to include env.json

Here’s some more explanation on the topic by @mika.

Using script from command line with rcc

enter command rcc task shell to open shell into environment
enter command use-robocorp-vault set and follow instructions
include devdata/env.json in a command rcc run -e devdata/env.json

Hope this helps!

2 Likes

This is great. It works!
This is my second day with Robot Framework and it’s pretty impressive. I actually used to use UiPath, but things can change quickly.

Thanks, I can now move foreward

3 Likes