devicesdk login

devicesdk login

Authenticate the CLI against the DeviceSDK server you run

Usage

devicesdk login [--host http://<server>:8080]
devicesdk logout
devicesdk whoami [--json]

Description

DeviceSDK is self-hosted, so the CLI needs to know which server to talk to. On most networks you can just run:

devicesdk login

The CLI auto-discovers your server over mDNS (default name: devicesdk.local). Pass --host when:

  • your network doesn't support mDNS (common on some corporate or VPN setups)
  • you set a custom MDNS_HOSTNAME on the server
  • the CLI is running on the same machine as the server
  • you want to target a server that isn't the default devicesdk.local
devicesdk login                                       # mDNS auto-discovery (devicesdk.local) - the default, no flag needed
devicesdk login --host http://localhost:8080          # CLI on same machine as the server
devicesdk login --host http://192.168.1.42:8080       # by IP

devicesdk login opens your browser to run a device-code flow against your server, then writes the access/refresh token pair and the host to ~/.devicesdk/credentials.json (file mode 0600). Subsequent CLI calls reuse the saved host and tokens automatically; the access token rotates on its own via the refresh token.

devicesdk logout removes ~/.devicesdk/credentials.json and revokes the refresh token server-side.

devicesdk whoami prints the currently-authenticated user. Pass --json for machine-readable output:

{ "success": true, "result": { "id": "user_…", "email": "you@example.com" } }

CI / non-interactive auth

Set DEVICESDK_TOKEN to a dsdk_… API token issued from your dashboard's Tokens page (the dashboard your server serves). The CLI checks this env var before falling back to ~/.devicesdk/credentials.json. In CI, also set the server URL with DEVICESDK_API_URL since there's no saved credentials file there:

export DEVICESDK_API_URL=http://<server>:8080
export DEVICESDK_TOKEN=dsdk_…
devicesdk deploy

Use a token with the minimum scope needed - most CI flows only need deploy and flash.

Switching servers

DEVICESDK_API_URL overrides the host saved in ~/.devicesdk/credentials.json. A token issued against one server is not accepted by another, so re-run login if you switch:

devicesdk login --host http://192.168.1.50:8080