Token service
Warning
Before you begin set the Access API Key as described in Getting started
Token service can be used to create access keys to your charts and share links or to create sessions. The main diffrence between access and session is that the session has sliding exparation.
Create shared link
var tokenService = new TokenService();
var resultCreateAccess = tokenService.CreateAccess(new OptionsCreateAccess
{
ExpireAfterMunutes = 10,
ResourceId = "CreateAccessChart",
Permissions = new Dictionary<string, bool>
{
{ "SharedReadAccess", true }
}
});
if (!resultCreateAccess.IsSuccess)
{
Console.WriteLine(resultCreateAccess.Error);
}
else
{
//Now you can share a link to "CreateAccessChart" chart
Console.WriteLine($"https://orgchart.balkan.app/org/MyChartName?ak={resultCreateAccess.Key}");
}
}
Create session and use the API from javascript
var tokenService = new TokenService();
var resultCreateSession = tokenService.CreateSession(new OptionsCreateSession
{
ResourceId = "CreateSessionChart",
Permissions = new Dictionary<string, bool>
{
{ "Read", true },
{ "Write", true },
}
});
if (!resultCreateSession.IsSuccess)
{
Console.WriteLine(resultCreateSession.Error);
}
else
{
Console.WriteLine($"Session key: {resultCreateSession.Key}");
}
If you want to delete all sessions and access keys call "Empty" method
Note
The demo is located at GitHub