How do i generate a dashboard secure hash with Management API?
AnsweredThe following are pre-requisites to generate a secure hash:
- Management API access: needed to authenticate requests and generate encrypted hash for filters
Not sure if you have it? Navigate to your User Settings and Enable your Management API credentials or reach out to support@knowi.com.
Follow along once you have that ready...
- Firstly we need to request an access token using the Management API credentials. Update the following with your Management API client Id and client secret
curl -X POST https://knowi.com/api/1.0/login \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'client_id=[CLIENT_ID]' \
-d 'client_secret=[CLIENT_SECRET]'
If the request is successful the response should look something like this:
{"access_token":"6Obm0ezeLmthXve86wKPFrxwvvyupNELRBtv5ip7QOvYie","token_type":"Bearer","expires_in":3600}
Next, we're ready to create the secure hash using the access_token above.
- Replace with your dashboard Id and the contentFilter parameters, as listed below:
curl -X POST 'https://www.knowi.com/api/1.0/dashboards/[DASHBOARD_ID]/share/url/secure/hash' \
-H 'Authorization: Bearer 6Obm0ezeLmthXve86wKPFrxwvvyupNELRBtv5ip7QOvYie' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'contentFilters=[{"fieldName": "userId", "values": ["1231", "0132"], "operator": "="}]'
This will return an encrypted secure hash, which you can append to your dashboard share URL to be distributed or embedded:
{"secureHash":"/A1XSSrn73s2udek___t9pQ9UnD8C___hhATNphvTA2Zq9B8eSPThnPP8B+lKjQh8fmuhJ9NyyrPPAXF+AJEqBxdPSDhqUmWaEDp7XiQ8hS17B9U="}
That's it! You can find the full documentation here, https://knowi.com/docs/managementAPI.html#CreateDashboardSecureShareHash
Please sign in to leave a comment.
0 comments