Pick an auth strategy
The SDK supports two authentication strategies, both implementingIEksoAuth:
| Strategy | Use when |
|---|---|
ApiKeyAuth | Server-to-server, agents, CI runners, anything headless. Static credentials. |
RefreshableBearerAuth | You already have an OAuth token pair (e.g. obtained via the CLI’s device-flow login or the web app’s auth-code grant). Auto-refreshes on expiry. |
EksoClientOptions.Auth.
ApiKeyAuth
API keys are minted via the admin surface (POST /api/admin/api-key, or ekso api-key create --name "..." from the CLI). The response contains the raw key (ek_live_...) exactly once; capture it immediately and store somewhere safe.
- The key is sent as a
Bearertoken on every request. - It carries the permissions of the user who minted it.
- It does not expire on a timer (unless
ExpiresAtwas set at mint time). Rotate on a policy. - The backend stamps API-key requests with
Client=Sdk— see CLI/SDK marker.
- Embed long-lived keys in client-side code, mobile binaries, or browser-shipped JS.
- Commit keys to source control. Use a secrets manager (KeyVault, AWS Secrets Manager, env-var injection from CI).
RefreshableBearerAuth
Use this when you’ve obtained an access + refresh token pair from an interactive flow (typically OAuth 2.0 device code or authorization-code-with-PKCE).- The SDK transparently exchanges the refresh token for a new access + refresh pair when the access token nears expiry.
- The
TokensRefreshedevent fires after each rotation so you can persist the new pair. Without this hook, the next process invocation would try to refresh with a token the backend has already invalidated and trigger family-rotation replay detection. - Device-flow tokens carry
Client=Cli; webapp authorization-code tokens carry no client claim (treated asWebat the read site).
Custom HTTP base URL
For local development or self-hosted instances, override the base URL:https://{Tenant}.ekso.app.
Logging out / revoking
ForApiKeyAuth: revoke via the admin surface (POST /api/admin/api-key/{id}/revoke or ekso api-key delete <id>). The key stops working immediately on subsequent calls.
For RefreshableBearerAuth: there is no client-side “logout” — discard the stored token pair and the user’s session is effectively gone. The refresh token expires server-side on a sliding window of inactivity.
Token-store integration
The CLI persistsRefreshableBearerAuth tokens to a per-tenant credential store on disk (see EksoClientFactory in Ekso.Cli). If you’re embedding the SDK in your own app, design your token store the same way — keyed by (Tenant, ClientId, Environment) so multi-tenant or multi-environment installs don’t collide.
Next steps
- Quickstart — your first authenticated call.
- Error handling — what to expect when auth fails.
- CLI/SDK marker — server-side gating semantics that depend on which auth you chose.