【发布时间】:2020-06-19 06:27:33
【问题描述】:
我已关注this 并设法让我的笔记本在 Visual Studio 中运行。在 python 程序中,我有 dbutils.secrets.get 语句来读取 jdbc 连接字符串。
我知道我需要dbutils.secrets.setToken 来设置特权秘密令牌才能调用secrets.get。
我已经按照错误消息成功生成了一个令牌,并且程序可以正常工作。由于令牌仅持续 48 小时,今天它已过期。我使用相同的命令在笔记本中再次重新生成令牌并复制并粘贴到我的本地 python 程序并更新了 dbutils.secrets.setToken 中的值。
但是,当我再次重新启动程序时,我仍然收到此错误:
An error occurred while calling o23.get. :
java.lang.SecurityException: Accessing a secret from Databricks
Connect requires a privileged secrets token. To obtain such a token,
you can run the following in a Databricks workspace notebook:
displayHTML( "<b>Privileged DBUtils token (expires in 48 hours):
</b>" +
dbutils.notebook.getContext.apiToken.get.split("").mkString("<span/>"))
Then, run dbutils.secrets.setToken(<value>) locally to save the token.
Note that these tokens expire after **48 hours**.
我怀疑是否有任何本地缓存仍然保存令牌的旧值?我已经重新启动集群,似乎没有效果。
有人遇到同样的问题吗?还是我错过了什么?
【问题讨论】:
-
这里有同样的问题 :-( 我试着把它放到笔记本里:
ctx = dbutils.notebook.entry_point.getDbutils().notebook().getContext(); token = ctx.apiToken().get(); print(*token);但后来这不起作用:dbutils.secrets.setToken(token)扔:AttributeError: 'SecretsHandler' object has no attribute 'setToken'
标签: python token databricks