'Printing secret value in Databricks

Even though secrets are for masking confidential information, I need to see the value of the secret for using it outside Databricks. When I simply print the secret it shows [REDACTED].

print(dbutils.secrets.get(scope="myScope", key="myKey"))

Out:
[REDACTED]

How can I print the secret value?



Solution 1:[1]

Databricks redacts secret values that are read using dbutils.secrets.get(). When displayed in notebook cell output, the secret values are replaced with [REDACTED].

Although it is not recommended, there is a workaround to see actual value with a simple for loop trick. So, you will get the value separated by spaces.

value = dbutils.secrets.get(scope="myScope", key="myKey")

for char in value:
    print(char, end=" ")

Out:
y o u r _ v a l u e

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1