[英]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):
user
table (JSON containing specific field values each user is permitted to view)user
表中设置权限(包含每个用户允许查看的特定字段值的 JSON)access_token
in Anvil, based on hex md5 hash of a combination of user and unix timestamp, with one hour expiryaccess_token
的机制,基于十六进制 md5 hash 用户和 unix 时间戳的组合,一小时到期app_secret
securely in Anvil to authenticate inbound requestsapp_secret
以验证入站请求app_secret
and validates access_token
and returns JSON containing user_email
and permitted_accounts
app_secret
并验证access_token
并返回包含user_email
和permitted_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:现在我已经到了构建自定义连接器的地步,目的是构建流程的下一部分:
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 sectionaccess_token
传递给 Data Studio,并将其包含在嵌入 URL(报告将通过 iFrame 嵌入)中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."access_token
。 from this sectionapp_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 messageapp_secret
和access_token
命中 API 端点以验证并接收与access_token
关联的用户权限,如果验证检查通过 Anvil,否则返回适当的错误消息 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.