Share tokens
This feature is part of release 25.4
Introduction
When records are made available via the "Shares" functionality, a unique Share Token can be generated. This token is a JWT that encapsulates the necessary permissions to interact with the objects within that specific share.
Obtaining a share token
To obtain a JWT for accessing a specific share, you must exchange a Share ID for a Share Token. This is done by making a POST request to the /shares/{shareId}/token endpoint.
Note that you must already be an authenticated user to perform this action.
Endpoint
POST /v2/shares/:shareId/tokenURL Parameters
:shareId(string, required) - The unique identifier of the share
Example Response Body:
{
"ShareToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyLWlk..."
}The value of the ShareToken property is the JWT. You will use this token in the Authorization header for all subsequent API requests related to this share.
Using the share token
A critical aspect of using the Share Token is that all API requests must be routed through the mediahaven-rest-api/v2-jwt/ path instead of the mediahaven-rest-api/v2/ path.
Example
Suppose you want to retrieve the details of a record, and the standard endpoint is:
https://integration.mediahaven.com/mediahaven-rest-api/v2/records/{recordId}To access this endpoint using your Share Token, you would modify the request path as follows:
https://integration.mediahaven.com/mediahaven-rest-api/v2-jwt/records/{recordId}Therefore, a complete curl request would look like this:
curl -X GET "https://webservice_base_url/v2-jwt/records/{recordId}" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyLWlk..."