简体   繁体   English

Google Data Studio 社区连接器:在 App 脚本中访问 URL 参数

[英]Google Data Studio Community Connector: Accessing URL Parameters in App Script

I am following the Row level filtering with Embedded dashboards tutorial to build a secure, multi-tenant dashboard using Data Studio as the reporting UI/backend (and Anvil as the front-end in Python), with the aim of filtering data from a BigQuery table based on specific user permisisons.我正在按照使用嵌入式仪表板进行行级过滤教程构建一个安全的多租户仪表板,使用 Data Studio 作为报告 UI/后端( Anvil作为 Python 的前端),目的是从 BigQuery 中过滤数据基于特定用户权限的表。

I have completed the initial connector tutorial successfully as recommended.我已经按照推荐成功完成了初始连接器教程 So far I have also completed the following steps (1-4) successfully:到目前为止,我还成功完成了以下步骤(1-4):

  1. Build user authentication in Anvil and set permissions in user table (JSON containing specific field values each user is permitted to view)在 Anvil 中构建用户身份验证并在user表中设置权限(包含每个用户允许查看的特定字段值的 JSON)
  2. Build mechanism to create access_token in Anvil, based on hex md5 hash of a combination of user and unix timestamp, with one hour expiry构建在 Anvil 中创建access_token的机制,基于十六进制 md5 hash 用户和 unix 时间戳的组合,一小时到期
  3. Set and store app_secret securely in Anvil to authenticate inbound requests在 Anvil 中安全地设置和存储app_secret以验证入站请求
  4. Create API endpoint in Anvil which validates the app_secret and validates access_token and returns JSON containing user_email and permitted_accounts在 Anvil 中创建 API 端点,它验证app_secret并验证access_token并返回包含user_emailpermitted_accounts的 JSON

Now I've got to the point of building the custom connector, with the aim of building the next part of the flow:现在我已经到了构建自定义连接器的地步,目的是构建流程的下一部分:

  1. Pass access_token to Data Studio by encoding and including it in the embed URL (the report will be embedded via an iFrame) as per this section根据节,通过编码将access_token传递给 Data Studio,并将其包含在嵌入 URL(报告将通过 iFrame 嵌入)中
  2. Extract access_token from embed URL in App Script as per the statement "This will be used to capture a token from embed URL's parameters."根据语句“这将用于从嵌入 URL 的参数中捕获令牌”,从 App 脚本中的嵌入 URL 中提取access_token from this section这个部分
  3. Hit the API endpoint with the app_secret and access_token from App Script to validate and receive the user permissions associated with the access_token IF validation checks pass in Anvil, otherwise return appropriate error message使用 App Script 中的app_secretaccess_token命中 API 端点以验证并接收与access_token关联的用户权限,如果验证检查通过 Anvil,否则返回适当的错误消息
  4. Construct query based on user permissions and get data from BigQuery using this approach ... then set schema etc...基于用户权限构建查询并使用这种方法从 BigQuery 获取数据......然后设置模式等......

However, upon reaching step 6 in this flow where I need to parse the access_token from the URL, the code included in the Write the Connector Code section takes the token as a user-inputted text field and does not take it from the embed URL's parameters (which to me makes no sense as making a user continually manually transpose a short-lived token seems to negate the point of this exercise).但是,在到达此流程中我需要从 URL 解析access_token的第 6 步时,“ 编写连接器代码”部分中包含的代码将token作为用户输入的文本字段,而不是从嵌入 URL 的参数中获取(这对我来说毫无意义,因为让用户不断地手动转置一个短暂的令牌似乎否定了这个练习的意义)。

I am also unable to find documentation in the API reference on how to achieve this.我也无法在API 参考中找到有关如何实现此目的的文档。

PLEASE, does anybody know how to capture parameters from Report Embed URLs in an App Script Community Connector?请问,有人知道如何从应用脚本社区连接器中的报告嵌入 URL 捕获参数吗? I assumed it was possible from the documentation:我认为可以从文档中获得:

getConfig() should return at least one config item. getConfig() 应该至少返回一个配置项。 This will be used to capture a token from embed URL's parameters.这将用于从嵌入 URL 的参数中捕获令牌。

Thank you for taking the time!感谢您抽出宝贵时间!

a. A。 I'm assuming access_token is an overridable config parameter in your getConfig .我假设access_token是您的getConfig中的可覆盖配置参数。

b. b. When you create the initial report, during the data source creation, you can put in any value in access_token config field.当您创建初始报告时,在数据源创建期间,您可以在access_token配置字段中输入任何值。 However, check the box to 'Allow "access_token" to be modified in reports'.但是,选中“允许在报告中修改“access_token””复选框。 That means, report viewers will be able to override this value even though they do not have edit access to the report or the data source.这意味着,报表查看者将能够覆盖此值,即使他们没有报表或数据源的编辑权限。

c. Confirm that your setp #5 is following the instructions here to pass the override value for access_token . c。确认您的 setp #5 正在按照此处的说明传递access_token的覆盖值。

d. d. That's it.就是这样。 Now it is irrelevant what value you put in for access_token during initial report creation.现在,您在初始报告创建期间为access_token设置的值无关紧要。 For user X, your portal was pass the value hash(user, timestamp) as the value for access_token .对于用户 X,您的门户传递值hash(user, timestamp)作为access_token的值。 In your connector's getData function, request.configParams.access_token will return that specific value.在连接器的getData function 中, request.configParams.access_token将返回该特定值。 You can then call your endpoint with that value to get back the user identity.然后,您可以使用该值调用端点以取回用户身份。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 Google Data Studio 社区连接器与 BigQuery 结合使用时的时间戳查询问题 - Timestamp query issue when using Google Data Studio community connector with BigQuery Data Studio Community Connector:如何更改数据新鲜度间隔 - Data Studio Community Connector: How to change Data freshness interval Google Data Studio - 自定义连接器 - 获取数据解析 json - Google Data Studio - Custom Connector - Get Data parsing json 如何使用用户可以在 getFields 的计算字段中更新的参数(Data Studio 社区连接器) - How to use a parameter which a user can update in a calculated field in getFields (Data Studio Community Connector) 使用 Google Apps 脚本在 Google Data Studio 上自动刷新 - Auto Refresh on Google Data Studio using Google Apps Script Data Studio 自定义连接器字段数量错误 - Data Studio Custom Connector wrong amount of fields Google Data Studio URL 参数不会自动更新引用它的字段 - Google Data Studio URL Parameter not automatically updating a field that refers to it Google 数据洞察中的运行平均值 - Running Average in Google Data Studio Google Data Studio 中的千位分隔符 - Thousand separator in Google Data Studio 为 Google Cloud Storage 导出配置连接器配置文件的正确 URL 是什么? - What is the correct URL to export a config-connector config file for Google Cloud Storage?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM