A Sys.tm® package for authentication and utilizing the Sys.tm API.
$ dotnet add package Systm.AppServicesThe Systm.AppServices library provides a robust framework for managing sessions, tokens, and various system-level operations in applications. It is designed to work with .NET Standard 2.0 and .NET Framework 4.7.2, ensuring compatibility across a wide range of platforms.
Install the package via NuGet Package Manager:
Install-Package Systm.AppServices
Or via the .NET CLI:
dotnet add package Systm.AppServices
SystmManagerThe SystmManager class is the entry point for managing sessions, tokens, and making API calls.
Note: Before utilizing the Sys.tm API, you will need to be issued an API key by contacting support@sys.tm.
using SYSTM.AppServices;
using SYSTM.AppServices.Models;
var sysConfig = new SysConfig
{
ApiKey = "My_Systm_API_Key"
};
SystmManager systmManager = new SystmManager(sysConfig, null);
//This ID is for the Sys.tm External API App Client and cannot be changed
string clientId = "10j898a433qi77projmk4bc7r7";
string deviceName = "YourDeviceName";
var sysConfig = await SystmManager.GetDefaultSysConfig();
sysConfig.ApiKey = "My_Systm_API_Key";
SystmManager systmManager = new SystmManager(sysConfig, null);
var initialResponse = await systmManager.TokenService.DeviceAuth_Start(clientId, deviceName);
if (!initialResponse.IsSuccess)
{
throw new Exception(initialResponse.Error);
}
//Use the default browser to show the Sys.tm authentication page
System.Diagnostics.Process.Start(initialResponse.verification_uri_complete);
CancellationTokenSource source = new CancellationTokenSource();
systmManager.SystmCredentials = await systmManager.TokenService.WaitForDeviceAuth(clientId, initialResponse, source.Token);
var organizationsResult = await systmManager.GetOrganizations();
if (organizationsResult.IsSuccess)
{
foreach (var org in organizationsResult.Organizations)
{
Console.WriteLine($"Organization: {org.Name} (ID: {org.Id})");
}
}
else
{
Console.WriteLine($"Failed to retrieve organizations: {organizationsResult.Message}");
}
var initResult = await systmManager.InitSession("organizationId123");
if (initResult.CreatedSession)
{
Console.WriteLine("Session created successfully.");
}
else
{
Console.WriteLine($"Failed to create session: {initResult.Message}");
}
var session = await systmManager.GetSession("entityId123");
Console.WriteLine($"Session ID: {session.Id}");
await systmManager.RefreshSystmCredentials();
Console.WriteLine("Credentials refreshed successfully.");
var accessToken = @"Access_Token_From_Systm_Device_Authorization";
var refreshToken = @"Refresh_Token_From_Systm_Device_Authorization";
string orgId = "Organization_ID_From_GetOrganizations_Call";
string fileId = "My_File_ID";
var sysConfig = await SystmManager.GetDefaultSysConfig();
sysConfig.ApiKey = "My_Systm_API_Key";
SystmManager systmManager = new SystmManager(sysConfig, null);
systmManager.SystmCredentials = await systmManager.TokenService.GetCredentialsFromJwtAuth(accessToken, refreshToken);
await systmManager.InitSession(orgId);
NameValueCollection queryStringParams = new NameValueCollection() { { "Id", fileId } };
ApiResponse response = await systmManager.MakeApiCall("files", Method.GET, queryStringParams, string.Empty);
string s3Key = response.JsonResult.GetProperty("S3Key").GetString();
var accessToken = @"Access_Token_From_Systm_Device_Authorization";
var refreshToken = @"Refresh_Token_From_Systm_Device_Authorization";
string body = "{\"ContentModified\":\"1997-07-25T14:07:49.0156138-06:00\", \"PageSizeLimit\":100}";
var sysConfig = await SystmManager.GetDefaultSysConfig();
sysConfig.ApiKey = "My_Systm_API_Key";
SystmManager systmManager = new SystmManager(sysConfig, null);
systmManager.SystmCredentials = await systmManager.TokenService.GetCredentialsFromJwtAuth(accessToken, refreshToken);
await systmManager.InitSession(orgId);
ApiResponse response = await systmManager.MakeApiCall("folders/contents/modified", Method.POST, null, body);
var folders = response.JsonResult.GetProperty("Folders");
var firstFolder = folders[0];
string firstModifiedFolderName = firstFolder.GetProperty("Name").GetString();
This library depends on the following NuGet packages:
System.Text.JsonMicrosoft.AspNetCore.StaticFilesAWSSDK.CoreAWSSDK.CognitoIdentityAWSSDK.CognitoIdentityProviderAWSSDK.S3.NET Standard 2.0.NET Framework 4.7.2This library is licensed under the Digitech Systems, LLC end user license agreement.