首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Python在数据库中验证Looker

无法使用Python在数据库中验证Looker
EN

Stack Overflow用户
提问于 2019-10-30 17:43:43
回答 1查看 199关注 0票数 0

我想访问一些图表,我已经保存在中。此过程的一部分是身份验证。我有一个Looker脚本,它可以工作,但只将表格结果拉到Databricks中,它对应于Looker。相反,我只想在Databricks中访问图表,这将对应于Looker或Looker。但是,当我在https://discourse.looker.com/t/generating-a-powerpoint-presentation-from-all-looks-in-a-space/8191上学习教程时,我无法使用它们的脚本进行身份验证。希望有人能帮忙。

代码语言:javascript
复制
**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/'

我尝试将代码从当前转换为所需的auth脚本,但是错误声明looker_client未定义!

代码语言:javascript
复制
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方面提供帮助。谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-31 20:24:14

看起来这个问题在这里已经解决了:对于那些跟随在家里的人来说,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错误:

代码语言:javascript
复制
import looker_client_30 as looker_client
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58631027

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档