我想访问Databricks中保存在Looker中的一些图表。此过程的一部分是身份验证。我有一个Looker身份验证脚本,该脚本可以工作,但只能将表格结果拉入与Looker-View相对应的Databricks中。相反,我只希望在Databricks中访问图表,这些图表将对应于Looker-look或Looker-space。但是,当我按照https://discourse.looker.com/t/generating-a-powerpoint-presentation-from-all-looks-in-a-space/8191上的教程进行操作时,无法使用其脚本进行身份验证。希望有人可以提供帮助。
**Working auth-script for Looker-Views**
import looker_tools as tools
api=tools.LookerApi(
api_endpoint="abcd",
client_id=dbutils.secrets.get(scope="looker-api", key="looker_client_id"),
client_secret=dbutils.secrets.get(scope="looker-api",key="looker_client_secret")
)
token = api.login()
**Desired auth-script for Looker-Space/Looks as per tutorial link**
looker_instance = 'your-company.looker.com'
target_space = # 'Period over Period' Space on the Looker instance
client_id = 'xxxxxxxx'
client_secret = 'xxxxxxxx'
# instantiate Auth API
unauthenticated_client = looker_client.ApiClient(configuration=None)
unauthenticated_client.configuration.host = f'https://{looker_instance}:19999/api/3.0/'
unauthenticated_authApi = looker_client.ApiAuthApi(unauthenticated_client)
# authenticate client
token = unauthenticated_authApi.login(client_id=client_id, client_secret=client_secret)
client = looker_client.ApiClient(header_name='Authorization', header_value='token ' + token.access_token)
client.configuration.host = f'https://{looker_instance}:19999/api/3.0/'
我尝试将代码从Current转换为DESIRED auth-script,但是错误指出looker_client未定义!
looker_instance = 'abcd'
target_space = 123
client_id = dbutils.secrets.get(scope="looker-api", key="looker_client_id")
client_secret = dbutils.secrets.get(scope="looker-api",key="looker_client_secret")
# instantiate Auth API
unauthenticated_client = looker_client.ApiClient(configuration=None) --> This line fails!!
unauthenticated_client.configuration.host = f'https://{looker_instance}:19999/api/3.0/'
unauthenticated_authApi = looker_client.ApiAuthApi(unauthenticated_client)
# authenticate client
token = unauthenticated_authApi.login(client_id=client_id, client_secret=client_secret)
client = looker_client.ApiClient(header_name='Authorization', header_value='token ' + token.access_token)
client.configuration.host = f'https://{looker_instance}:19999/api/3.0/'
我希望有人能帮助您正确定义looker_client。谢谢。
答案 0 :(得分:0)
看来此问题已在此处解决:https://discourse.looker.com/t/generating-a-powerpoint-presentation-from-all-looks-in-a-space/8191/15?u=izzy供那些在家中跟随的人使用。还有另一个问题,但是NameError: name ‘looker_client’ is not defined
错误通过添加必要的导入得以解决:
import looker_client_30 as looker_client