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.
I have completed the initial connector tutorial successfully as recommended. So far I have also completed the following steps (1-4) successfully :
- Build user authentication in Anvil and set permissions in
usertable (JSON containing specific field values each user is permitted to view) - Build mechanism to create
access_tokenin Anvil, based on hex md5 hash of a combination of user and unix timestamp, with one hour expiry - Set and store
app_secretsecurely in Anvil to authenticate inbound requests - Create API endpoint in Anvil which validates the
app_secretand validatesaccess_tokenand returns JSON containinguser_emailandpermitted_accounts
Now I've got to the point of building the custom connector, with the aim of building the next part of the flow:
- Pass
access_tokento Data Studio by encoding and including it in the embed URL (the report will be embedded via an iFrame) as per this section - Extract
access_tokenfrom embed URL in App Script as per the statement "This will be used to capture a token from embed URL's parameters." from this section - Hit the API endpoint with the
app_secretandaccess_tokenfrom App Script to validate and receive the user permissions associated with theaccess_tokenIF validation checks pass in Anvil, otherwise return appropriate error message - Construct query based on user permissions and get data from BigQuery using this approach ... then set schema etc...
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).
I am also unable to find documentation in the API reference on how to achieve this.
PLEASE, does anybody know how to capture parameters from Report Embed URLs in an App Script Community Connector? I assumed it was possible from the documentation:
getConfig() should return at least one config item. This will be used to capture a token from embed URL's parameters.
Thank you for taking the time!
a. I'm assuming
access_tokenis an overridable config parameter in yourgetConfig.b. When you create the initial report, during the data source creation, you can put in any value in
access_tokenconfig field. However, check the box to 'Allow "access_token" to be modified in reports'. 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.d. That's it. Now it is irrelevant what value you put in for
access_tokenduring initial report creation. For user X, your portal was pass the valuehash(user, timestamp)as the value foraccess_token. In your connector'sgetDatafunction,request.configParams.access_tokenwill return that specific value. You can then call your endpoint with that value to get back the user identity.