PAT, Iframes, & Redirects

The documentation around Personal Access Tokens mentions using the browser context type PAT for public portals and specifically mentions iframes. I’m working on a simple proof of concept to display a dashboard via an iframe using PAT. I like this potential solution for embedding a single dashboard as it is faster than rebuilding the visualizations outside of DHIS2 with chartJS.

I’ve had to tweak some x-frame-options in NGINX to specify fame ancestors to get to the DHIS2 Login page. However, now that I am using the PAT to authenticate and specifying the iframe src as a dashboard page I am continually redirected back to the login page. It is the same behavior as if I was requesting the dashboard page via the API.

Basically, I’m not sure what question to ask now - I don’t know what is driving DHIS2 to return the login page even with correct authentication. I assume it has to do with the type of data that can be returned.

I’m asking for help with my next bread crumb to solve this issue or better yet, if someone else knows how to do it!

1 Like

I suppose another logical question to ask is if these docs are still the best approach to embed visuals: Visualizations - DHIS2 Documentation

I’ve seen that Tanzania has used high charts for their great embedded visualizations.

Hi @chase.freeman

What are you sharing? Dashboard, visualization? Either way, did you make sure to change the ‘external access’ setting to true?

Try this: [INSTANCE-URL-HERE]/api/sharing?type=[METADATA-HERE]&id=[UID-HERE]

After that please test your request :slight_smile:

Hi @Gassim - I want to share a dashboard, however even a visualization would be nice. Can you instruct me on how to find the "external access sharing setting? I can’t seem to find it (superuser privileges). I’m referencing these docs:

You can find it in the URL request above. “allowExternalAccess” and if you send a post request to the URL above with JSON

"allowExternalAccess": true