Help using robocorp vault, please!

Hi there team!

I’ve almos finished level II certification exercise, but I still have to implement the read from vault requirement.

To do so, I’ve tried to run the example provided here : https://robocorp.com/portal/robot/robocorp/example-using-vault

But its impossible to me, I alwais get the same error
KeyError: ‘Undefined secret: credentials’

I’m using windows 10, so this is how I modified the env.json file attached in the example so that it can read the values from de variables.py file (RPA_SECRET_FILE with double backslashes):

{
“RPA_SECRET_MANAGER”: “RPA.Robocloud.Secrets.FileSecrets”,
“RPA_SECRET_FILE”: “Z:\Robocorp\example-using-vault\variables.py”
}

Does anybody know how i can solve this, or maybe some advise about it?

This is the log I get after running the robot:

20210717 18:10:58.537 ERROR Failed to load secrets file: Expecting value: line 1 column 1 (char 0)
20210717 18:10:58.538 ERROR Error in file ‘Z:\Robocorp\example-using-vault’ on line 4: Processing variable file ‘Z:\Robocorp\example-using-vault\variables.py’ failed: Importing variable file ‘Z:\Robocorp\example-using-vault\variables.py’ failed: KeyError: ‘Undefined secret: credentials’
Traceback (most recent call last):
File “Z:\Robocorp\example-using-vault\variables.py”, line 4, in
USER_NAME = secrets.get_secret(“credentials”)[“username”]
File “C:\Users\danic\AppData\Local\robocorp\live\d96e57c212cd468d\lib\site-packages\RPA\Robocloud\Secrets.py”, line 524, in get_secret
return self.adapter.get_secret(secret_name)
File “C:\Users\danic\AppData\Local\robocorp\live\d96e57c212cd468d\lib\site-packages\RPA\Robocloud\Secrets.py”, line 155, in get_secret
raise KeyError(f"Undefined secret: {secret_name}")
PYTHONPATH:
Z:\Robocorp\example-using-vault
Z:\Robocorp\example-using-vault
C:\Users\danic\AppData\Local\robocorp\live\d96e57c212cd468d\python37.zip
C:\Users\danic\AppData\Local\robocorp\live\d96e57c212cd468d\DLLs
C:\Users\danic\AppData\Local\robocorp\live\d96e57c212cd468d\lib
C:\Users\danic\AppData\Local\robocorp\live\d96e57c212cd468d
C:\Users\danic\AppData\Local\robocorp\live\d96e57c212cd468d\lib\site-packages
C:\Users\danic\AppData\Local\robocorp\live\d96e57c212cd468d\lib\site-packages\win32
C:\Users\danic\AppData\Local\robocorp\live\d96e57c212cd468d\lib\site-packages\win32\lib
C:\Users\danic\AppData\Local\robocorp\live\d96e57c212cd468d\lib\site-packages\Pythonwin
C:\Users\danic\AppData\Local\robocorp\live\d96e57c212cd468d\lib\site-packages\IPython\extensions
C:\ProgramData\Temp\rcd212b4.ipython
20210717 18:10:58.548 ERROR Failed to load secrets file: Expecting value: line 1 column 1 (char 0)

Kind regards, and thanks in advance

Daniel.

Welcome to the forum :sunny: Secrets file should be simple json. In your code seems you are using variables.py Here you can see example of vault.json file https://robocorp.com/docs/development-guide/variables-and-secrets/vault So your RPA_SECRET_FILE should point to the vault.json with credentials not to the variables.py

1 Like