multica-ai/multica · error

not authenticated: run 'multica login' first%s

Error message

not authenticated: run 'multica login' first%s

What it means

Shared helper fetchWorkspaces (used by `workspace list` and `workspace switch`) found no auth token: resolveToken returned an empty string for both the flag/env and stored credential. The suffix from daemonPortOnlyContextHint adds context when only a daemon port mismatch is involved.

Source

Thrown at server/cmd/multica/cmd_workspace.go:229

}

// workspaceSummary is the subset of fields the CLI needs from /api/workspaces
// to drive list and switch. Keeping it here (instead of using the full
// WorkspaceResponse) avoids a dependency on the handler package.
type workspaceSummary struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

// fetchWorkspaces lists all workspaces the authenticated user belongs to. It
// is shared by `list` and `switch` so both see the same access-controlled view
// of workspaces.
func fetchWorkspaces(ctx context.Context, cmd *cobra.Command) ([]workspaceSummary, error) {
	serverURL := resolveServerURL(cmd)
	token := resolveToken(cmd)
	if token == "" {
		return nil, fmt.Errorf("not authenticated: run 'multica login' first%s", daemonPortOnlyContextHint())
	}

	client := cli.NewAPIClient(serverURL, "", token)
	var workspaces []workspaceSummary
	if err := client.GetJSON(ctx, "/api/workspaces", &workspaces); err != nil {
		return nil, fmt.Errorf("list workspaces: %w", err)
	}
	return workspaces, nil
}

func runWorkspaceList(cmd *cobra.Command, _ []string) error {
	ctx, cancel := cli.APIContext(context.Background())
	defer cancel()

	workspaces, err := fetchWorkspaces(ctx, cmd)
	if err != nil {
		return err
	}

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Run `multica login` to obtain and store a token.
  2. If scripting/CI, supply the token explicitly via the token flag or environment variable instead of relying on the store.
  3. If you already logged in, verify the credential file exists and is readable by the current OS user (no permission errors in `multica login` output).

Example fix

# before
multica workspace list   # not authenticated

# after
multica login && multica workspace list
Defensive patterns

Strategy: validation

Validate before calling

command -v multica >/dev/null && multica login --check 2>/dev/null || echo 'no stored token; run multica login'

Prevention

When it happens

Trigger: Running `multica workspace list` or `workspace switch` before ever running `multica login`, or after the stored token file was removed, with no --token flag / MULTICA_TOKEN-style env override.

Common situations: Fresh installs, CI containers with no credential store, home-dir permission issues that silently prevent token persistence, or multiple profiles where login was done under a different user.

Understand the failure class

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/3715ecbada14d92a. Report an issue: GitHub.