Skip to content

plexctl whoami

Synopsis

plexctl whoami calls GET /v1/auth/whoami against the resolved plexsphere control plane using the configured bearer token and prints the principal the server resolved that token to. The command is the canonical sanity check after plexctl login: a successful call proves the persisted token reaches the API, the Authorization header is accepted, and the server can map it onto a Whoami projection (subject, principal_type, domain_id, acr, amr).

The output respects the persistent --output flag — text yields a tab-aligned table; json and yaml emit the typed Whoami payload verbatim so a CI script can scrape e.g. principal_type without post-processing.

Invocation

text
plexctl whoami [persistent flags]

The command takes no positional arguments and no command-specific flags. Behaviour is fully driven by the resolved profile + persistent flag bag.

Flags

whoami declares no command-specific flags. Every parameter the command consumes is inherited from the root command.

Persistent flags inherited from root

FlagTypeRequiredDefaultDescription
--serverstringconditionalprofile / PLEXSPHERE_URLAPI URL (https://host:port). Required when no profile is configured and PLEXSPHERE_URL is unset.
--profilestringnofile-level defaultNamed profile from the plexctl config file.
--token-filepathconditionalprofile / PLEXSPHERE_TOKENBearer token file (mode 0600). Required when no profile is configured and PLEXSPHERE_TOKEN is unset.
--outputenumnotextOutput format: text | json | yaml.
--yesboolnofalseInert for whoami (no destructive operation).
--reveal-secretsboolnofalseInert for whoami (no secret payload).

See plexctl.md for the canonical persistent-flag contract and the precedence chain enforced by profile.Resolve.

Exit codes

plexctl collapses every failure into the taxonomy below; the single source of truth is exitCodeFor in ../../../cmd/plexctl/app.go.

CodeReachableMeaning
0yesThe server returned 200 OK and the typed Whoami payload was rendered.
1yesRuntime / API error: transport failure, non-200 status that is neither 401 nor 403, or a malformed response body.
2yesFlag-parse / misconfiguration: unknown --output format or a typo on a persistent flag.
3yesMissing or insecure credentials: profile.ErrNoServer / profile.ErrNoToken, or 401 Unauthorized from the API mapped through output.DecodeProblem.
4yesPermission denied: 403 Forbidden from the API.
64noNot reachable — whoami is fully implemented and never returns *NotImplementedError.

Examples

Happy path

shell
export PLEXSPHERE_URL="${PLEXSPHERE_URL:-https://localhost:8080}"

plexctl whoami --server "${PLEXSPHERE_URL}"
text
PRINCIPAL  SUBJECT                               DOMAIN                                ACR  AMR
user       0190a8b8-a0c0-7a0a-8a0a-a0a0a0a0a0a1  0190a8b8-a0c0-7a0a-8a0a-a0a0a0a0a0a0  -    -

JSON for scripting

shell
plexctl whoami --server "${PLEXSPHERE_URL}" --output json
json
{
  "principal_type": "user",
  "subject": "0190a8b8-a0c0-7a0a-8a0a-a0a0a0a0a0a1",
  "domain_id": "0190a8b8-a0c0-7a0a-8a0a-a0a0a0a0a0a0"
}

Missing credentials (exit 3)

shell
unset PLEXSPHERE_TOKEN
plexctl whoami --server "${PLEXSPHERE_URL}"
# stderr: no token available (set --token-file, PLEXSPHERE_TOKEN, or run 'plexctl login')
echo $?  # 3

profile.Resolve surfaces ErrNoToken before any HTTP request leaves the CLI; the dispatcher routes it to exit 3 per the shared exit-code taxonomy.

Cross-references