无法使用 Python 在 Databricks 中验证 Looker API
Unable to authenticate Looker API in Databricks using Python
我想访问 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。谢谢。
看起来这个问题已在此处解决: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
我想访问 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。谢谢。
看起来这个问题已在此处解决: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