Using Secrets From Databricks Connect

Normally in Databricks you get secret value by calling something like password = dbutils.secrets.get("scope", "password") but that won’t work in Databricks Connect - you will need to authorise local session to use secrets first. I’ve created a notebook in my personal workspace which prints code snippet every time I need to do that:

%scala
displayHTML(
  "<b>Privileged DBUtils token (expires in 48 hours): </b> dbutils.secrets.setToken(\"" +
  dbutils.notebook.getContext.apiToken.get.split("").mkString("<span/>") +
  "\")")

prints something like:

Privileged DBUtils token (expires in 48 hours): dbutils.secrets.setToken("thetoken")
Have a question⁉ Contact me.