TenantCloud does not offer a public OAuth or API-key flow. This library authenticates by extracting JWT tokens from a running browser session via the Chrome DevTools Protocol (CDP).
- Browser extraction — connects to a Chromium browser's CDP debug port, looks for a tab on
app.tenantcloud.com, and readsaccess_token+fingerprintfromlocalStorageandtc_refresh_tokenfrom cookies - Token refresh — when the JWT expires, the library calls TenantCloud's refresh endpoint with the refresh token and fingerprint
- Persist & loop — refreshed tokens are saved to the configured
ITcTokenStorefor next launch
If AllowInteractiveLogin is enabled and no existing session is found, the provider launches a temporary Chromium instance pointing to the TenantCloud login page. Once you sign in, tokens are extracted automatically.
Tokens can survive across process restarts via ITcTokenStore:
public interface ITcTokenStore
{
Task<TcTokenSet?> LoadAsync(CancellationToken ct);
Task SaveAsync(TcTokenSet tokens, CancellationToken ct);
}Uses the OS-native credential store:
| OS | Backend |
|---|---|
| Windows | DPAPI (CredWrite / CredRead) |
| macOS | Keychain (security CLI) |
| Linux | Secret Service D-Bus API |
services.AddSecureTokenStore();
// With custom options
services.AddSecureTokenStore(options =>
{
options.ServiceName = "MyApp";
options.AccountKey = "production";
});Plain JSON file with atomic writes. Useful for headless/CI scenarios where no credential store is available:
services.AddSingleton<ITcTokenStore>(new FileTokenStore("/path/to/tokens.json"));Security note: the file contains sensitive refresh tokens. Protect it with appropriate file permissions.
Implement ITcTokenStore to persist tokens wherever you need (database, Azure Key Vault, etc.):
services.AddSingleton<ITcTokenStore, MyDatabaseTokenStore>();The token provider is responsible for supplying Bearer tokens to TcClient:
public interface ITcAuthTokenProvider
{
Task<string?> GetToken(CancellationToken ct);
Task OnTokenRejected(CancellationToken ct, string rejectedToken);
}Provided by the Yllibed.TenantCloudClient.Cdp package. Multi-step strategy:
- In-memory cache (if the JWT is still valid)
- Token store (load + refresh if expired)
- CDP extraction from an existing browser tab
- Interactive login (if
AllowInteractiveLoginis enabled)
services.AddCdpTokenProvider(options =>
{
options.DebugPort = 9222;
options.AllowInteractiveLogin = true;
});services.AddSingleton<ITcAuthTokenProvider, MyCustomTokenProvider>();
services.AddTenantCloudClient();