Keep the credential off the page
A share link’s token is fine for a dashboard anyone with the link may see, but a token written into a web page can be read by anyone who opens it. When each visitor should see only their own rows, keep an embed key on your server (Settings, API tokens, type Embed key) and have your server ask for a short-lived session for each visitor:
curl -X POST "https://eventhorizondata.com/api/v1/embed-sessions" \
-H "Authorization: Bearer $EH_EMBED_KEY" \
-H "Content-Type: application/json" \
-d '{
"share_link_id": "<share link id>",
"expires_in": 600,
"row_scope": [{ "event_bucket_id": "<bucket id>", "column_key": "region", "values": ["EMEA"] }]
}'
# { "data": { "token": "ehs_...", "expires_at": "..." } }Give the page only the session token. It works for the number of seconds you asked for (60 to 3,600, ten minutes by default), shows what the share link shows narrowed to the rows you named, and then stops. The element asks your endpoint for one itself, and the module takes tokenFromUrl, or any function that returns a token:
<!-- /eh/session is YOUR endpoint: it makes the request above and returns the answer --> <eh-chart token-url="/eh/session" widget="<widget id>" style="height: 320px"></eh-chart>
import { createClient, tokenFromUrl } from '@event-horizon-data/charts';
// tokenFromUrl asks YOUR endpoint; any function that returns a token works too.
const client = createClient({ token: tokenFromUrl('/eh/session') });The embed key can read no data, and the session can only narrow the link, never widen it. Revoke the key, or switch the link off, and every session under it stops at once. The library fetches a session on first use, again shortly before it expires, and once more if the API answers 404 to a session it handed out earlier.
Send your first event.
Create an account and get from raw data to a dashboard in minutes.