Shared C# client used by SimplyPrint's desktop CAD add-ins (SolidWorks, Alibre, …).
It is the formalisation of the client the Python integrations copy-port
(api.py / oauth.py / config.py): OAuth2 PKCE, chunked temp upload, .env
configuration, and token / preferences storage under ~/.simplyprint/.
Everything host-specific is injected via IntegrationProfile, so a single build
serves every add-in.
| File | Role |
|---|---|
IntegrationProfile.cs |
The per-integration identity + SimplyPrintClient.Init(profile) entry point. |
Config.cs |
.env loader (defaults ← profile, then ~/.simplyprint/.env, <addin>/.env, real env vars). |
OAuth.cs |
OAuth2 Authorization-Code + PKCE (S256) flow with a loopback TcpListener callback. |
ApiClient.cs |
GET /account/GetUser, POST /files/TempUpload, chunked POST /files/ChunkReceive, panel import URLs. |
Storage.cs |
TokenStore (profile-named token file) + PreferenceStore (host-supplied schema). |
Http.cs / Json.cs |
Process-wide HttpClient (TLS 1.2/1.3) and in-box JSON helpers. |
The backend contract is upload-then-hand-off: authenticate → upload the mesh to
temp storage → open the browser at https://{domain}/panel?import=tmp:{uuid}.
There is no "create print job" API — job creation happens in the web panel.
using SimplyPrint.Integrations.Core;
// Once, at add-in load:
SimplyPrintClient.Init(new IntegrationProfile
{
DefaultClientId = "simplyprintalibre",
DefaultCallbackPort = 21334,
UserAgent = "SimplyPrint Alibre Plugin",
TokenFileName = "oauth_alibre.json",
PrefsSubdir = "alibre",
});
// Log in (background thread; callback marshalled by the caller):
OAuth.StartFlow(result =>
{
if (result.Success) TokenStore.Save(result.ToTokens());
});
// Upload an exported mesh:
var resp = ApiClient.UploadFile(bytes, "part.stl", TokenStore.Load().AccessToken);
var uuid = Json.GetString(resp, "uuid");
System.Diagnostics.Process.Start(ApiClient.MakeImportUrl(uuid, "part.stl"));dotnet build -c Release
Targets net48 (referenced fine by net481 add-ins) and uses the
Microsoft.NETFramework.ReferenceAssemblies package so it builds on Linux/CI with
the dotnet CLI — no Windows Developer Pack required.
solidworks-integration(SimplyPrintSolidWorks)alibre-integration(SimplyPrintAlibre)
Each add-in references this project. Once this repo has a Git remote, wire it into
the consumers as a submodule at core/ and point the <ProjectReference> there;
until then the consumers reference it by relative path.