Reputation: 375
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: https://developers.google.com/datastudio/solution/viewers-cred-with-3p-credentials
My connector uses getConfig() and getData() to pass a token into an API endpoint, and that API endpoint returns data specific to that user.
The connector works perfectly when I pass in a token in the GUI by modifying the configuration, but doesn't work when I try to pass in the token using the embedded url.
User Token = 5wKu4QLvc9PC7tkPyg
Steps:
User Token = z6ps6Vhb9hzB333gG4
Steps:
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)
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=%22%7B%5C%22token%5C%22:%20%5C%22z6ps6Vhb9hzB333gG4%5C%E2%80%9D%7D%E2%80%9D
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.
Upvotes: 1
Views: 806
Reputation: 375
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.ds0.token
https://datastudio.google.com/embed/reporting/[report_id_here]/page/[page_id_here]?params=%7B"[name_from_step_2]":"[value]"%7D
Which for me translated into:
https://datastudio.google.com/embed/reporting/9dea8b8a-5b51-4add-adb2-afda3861b241/page/VXkvC?params=%7B"ds0.token":"12345"%7D
Which in raw URL format looks like: https://datastudio.google.com/embed/reporting/9dea8b8a-5b51-4add-adb2-afda3861b241/page/VXkvC?params=%7B"ds0.token":"12345"%7D
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.
Upvotes: 2