Token Options
Options for generating an Auth Token to embed a dashboard
Overview
This section outlines the different options available for generating AuthToken
.
AuthToken
is a unique, time-sensitive token that secures access to your dashboard. To generate this token, you need to include DASHBOARD_ID
and DASHBOARD_SECRET
as required fields in the request body, as shown below:
Token Expiry
By default, the AuthToken
is valid for 1 hour. However, you can specify a custom expiry time in the request body. Once the token expires, it will no longer be valid, and you will see a "Session expired" message on the dashboard.
The token expiry is specified in seconds. For example, to set the expiry time to 10 minutes, you can pass tokenExpiry: 60 * 10
in the request body.
This token will remain valid for 10 minutes. This feature is particularly useful if you want to synchronize your application's session timeout with the dashboard, ensuring a seamless and consistent user experience.
You can also explicitly invalidate the token by calling the invalidateToken
function when the user logs out of your application.
The invalidateToken
function sends a POST request to https://semaphor.cloud/api/v1/invalidate-token
to revoke the current session. The request includes the active accessToken
in the Authorization
header.
User Params
In some instances, you may want to pass user specific information to the dashboard. For example, the currency of the user's region. You can pass this information in the params
field in the request body.
Before rendering the currency for the numbers on the dashboard, Semaphor will first check if the currencyFormat
is set in the params
field of the AuthToken
. If it is, Semaphor will use the currency format specified in the params
field. If not, Semaphor will default to the currency format specified in the dashboard settings.
The locale
and the currency
fields must conform to the Intl.NumberFormat format.
Security Policies
The AuthToken
also controls what data user can see in the dashboard. You can set up security policies to restrict the data that a user can access. For more information, see Security & Multi-tenancy section.