Question on GD CN v2.3 Dashboard component - expor...
# gooddata-ui
s
Question on GD CN v2.3 Dashboard component - export pdf - does this work with apikey authentication? I'm currently getting a redirect to the login screen instead of a download prompt for the exported pdf
i
Hi Sheldon, Yes, your assumption is correct and you can find more details and examples here. Please be aware this a BETA feature.
s
Is there a way to intercept the redirect once the pdf has been generated?
Actually does the export controller support API key authentication? It seems the xhr request to get the pdf needs to hand control back to the browser (so the download can happen) to invoke the pdf uri and that requires authentication ... taking us to the login page .. once logged in (which is my problem) the pdf gets downloaded
If possible can the pdf download URI work with the authentication context established by the dashboard component?
j
Hi Sheldon, I believe export controller should support API token authentication. Can you share a code snipped how the dashboard component is implemented (with any sensitive information redacted)?
s
@Jan Kos I have the dashboard component embedded in an iframe - this works with API token authn. When the export to pdf button is clicked.. the pdf generation request is made and the polling to get the generated pdf begins - right? Once the polling API call gets a 200 response, it attempts to reload the iframe with the URI to get the pdf file. I believe this is because an xhr request cannot trigger a file download prompt on the browser window. This can only happen if the browser submits a request that results in a file download response. The problem is that this browser/iframe reload doesnt carry the authn context and gets redirected to the gooddata login screen.
I believe the issue may be with the API token authn not setting an HTTP ONLY cookie that carries the authn cookie
@Jan Kos any updates on this support/issue? Something I can do differently to make it work?
j
Hi Sheldon, I’m sorry for the delay, I’m still checking on it, I’ll keep you posted.
Hi Sheldon, so far I wasn’t able to replicate it. Export works form me with API authentication when embedded. Can you share more details how is your dashboard embedded (snippet). Is it a plain iFrame?
s
@Jan Kos Hi, following up on this again .. what I have is the Dashboard component embedded in angular app which is iframed within an angularjs app ... yeah its hairy but it works for the most part. Now, what I see when the export to PDF is clicked is that the request to generate the PDF is made, then polled till the job is completed. When completed - an anchor is created with its download attribute set to the url of the visualization that was being polled and the anchor is clicked programmatically. Now, this anchor click behavior does not have the Authorization header set and that results in a 302 whcih then ends up on the login screen. Can you confirm this behavior?
Also not sure if this is impeded by the same-origin policy restriction for the download attribute