I would like to display personalized ckan feeds on a cms website
I have a django cms website. The website is using RSS Plugin to display ckan feeds. Currently, I am using http://thedatahub.org/feeds/dataset.atom as described here to show ckan feed on my csm website. This works well but it shows public feed for a whole CKAN instance. But I would like to show private feed for the authenticated user.
I am using django-allauth
to authenticate users across the two websites.
So I expect to retrieve ckan feeds from ckan and display it on the cms plugin. I only need feeds that the user subscribed to and not public feeds.
I found a solution to this question.
First, we need the correct API endpoint to get current user dashboard activities. For my case I used /api/3/action/dashboard_activity_list_html
. This API endpoint needs CKAN API key to authenticate the user.
So something like this will work
from urllib.request import Request, urlopen
api_url_base = (
"https://myurl/api/3/action/dashboard_activity_list_html"
)
req = Request(api_url_base)
req.add_header("Authorization", api_key)
with urlopen(req) as response:
response_body = response.read()
return response_body