Home > Software engineering >  Google Data Studio Community Connector: Passing Token Through Embed URL Not Working
Google Data Studio Community Connector: Passing Token Through Embed URL Not Working

Time:06-22

I'm struggling to get a community connector to work for a web-app I'm building.

I wrote a very basic connector in App Script to do row level filtering on an embedded dashboard, using these docs Google provides: enter image description here enter image description here enter image description here

Example 2

User Token = z6ps6Vhb9hzB333gG4

Steps:

  1. Click "Edit connection"
  2. Enter token in input field [which is generated by getConfig() in app script]
  3. Click "Reconnect"
  4. Click "Apply" on dialogue box that comes up
  5. Google Data Studio correctly retrieves 1 row of data for this token

enter image description here enter image description here enter image description here

The primary issue

When I use the embed URL for the dashboard, I noticed the App Script execution logs aren't showing that getConfig or getData operations are being run.

The end result is the token doesn't appear to be passed into the embed URL at all. The data remains the same as in the GUI-based report.

However I can tell the embed URL is being invoked, because it does call getAuthType in the App Script execution logs, see image below. (I made the change in the GUI at 9:50:59 PM, and then the subsequent timestamps are me attempting to hit the embed URL)

Google App Script Logs

Sample

Here's the sample of the actual embed URL I'm using: https://datastudio.google.com/embed/reporting/9dea8b8a-5b51-4add-adb2-afda3861b241/page/VXkvC?config="{\"token\": \"z6ps6Vhb9hzB333gG4\”}”

Per the Example 2 above, the token being used in this embed URL should only return 1 row of data, but it's returning all 3.

I followed the Google docs, which suggest this is the format to use: https://datastudio.google.com/embed/reporting/[report_id_here]/page/[page_id_here]?config="{\"token\": \"[token_here]\”}”

I'm wondering if it's possible the Google docs are incorrect (or) out of date and my embed url is malformed? I can't get my head around this issue.

CodePudding user response:

Resolution

  1. Despite being part of the getConfig(), apparently you also have to "Add a Parameter" for the token to your Data Source on the report. This will result in the parameter being visible under all fields.
  2. Next, go to Resource > "Manage report url parameters" and check the box for "Allow to be modified in report URL". Take note of the "Name" field. Mine was ds0.token
  3. Finally, use this URL syntax: https://datastudio.google.com/embed/reporting/[report_id_here]/page/[page_id_here]?params={"[name_from_step_2]":"[value]"}

Which for me translated into: https://datastudio.google.com/embed/reporting/9dea8b8a-5b51-4add-adb2-afda3861b241/page/VXkvC?params={"ds0.token":"12345"}

Which in raw URL format looks like: https://datastudio.google.com/embed/reporting/9dea8b8a-5b51-4add-adb2-afda3861b241/page/VXkvC?params={"ds0.token":"12345"}

One additional observation. I was watching the logs on my API endpoint, and I noticed Google caches any data it brings back from the endpoint. So don't be surprised if you don't see a getData() call in your App Script execution logs for any tokens you've already passed. Just make up a new token to see a new getData execution log.

  • Related