Skip to content

feat: support multiple authentication profiles for the same workspace #89

Description

@rafael-yure

Motivation

SlackCLI currently stores authenticated credentials in workspaces.json keyed by Slack team_id:

{
  "workspaces": {
    "T123": {
      "workspace_id": "T123",
      "workspace_name": "example",
      "auth_type": "standard"
    }
  },
  "default_workspace": "T123"
}

This means authenticating a second identity or authentication mode for the same Slack workspace silently replaces the first one.

A common automation setup needs both:

  • a browser-authenticated user profile for workspace search, drafts, and user-authored messages;
  • a stable bot-token profile for unattended jobs and bot-authored messages.

SlackCLI supports both authentication modes individually, but cannot retain them simultaneously when they belong to the same Slack team.

Proposal

Allow authentication records to have unique, user-selected profile names:

slackcli auth login \
  --token=xoxb-... \
  --workspace-name=example \
  --profile=automation-bot

slackcli auth login-browser \
  --xoxd=xoxd-... \
  --xoxc=xoxc-... \
  --workspace-url=https://example.slack.com \
  --profile=rafael

Existing commands can continue using --workspace, extended to accept a profile name:

slackcli search messages "after:2026-07-01" --workspace=rafael --json
slackcli messages send --recipient-id=C123 --message="Done" --workspace=automation-bot

auth list, auth set-default, and auth remove should operate on and display the stored profile keys.

Compatibility

  • Existing workspaces.json files should continue working without manual migration.
  • Existing workspace ID and workspace name selectors should keep working when they resolve to exactly one profile.
  • If a workspace ID or name matches multiple profiles, SlackCLI should return a clear ambiguity error asking for a profile name instead of picking one silently.
  • Login without --profile should preserve today's behavior for users with one identity, while avoiding silent replacement when another profile already exists for that team.

Suggested implementation

  • Add an optional profile identifier to stored workspace configurations.
  • Store credential records by profile key rather than solely by team_id.
  • Extend workspace resolution to prefer exact profile keys/names, then fall back to an unambiguous workspace ID or name.
  • Normalize legacy records on load or support them transparently through the resolver.
  • Add focused tests for legacy config compatibility, two profiles in one team, ambiguous selection, defaults, and removal.

This keeps the Slack client and dual-auth implementation unchanged; the enhancement is isolated to authentication commands, configuration persistence, selection, and documentation.

Fork

I'm working on this on a personal fork; let me know if it's okay to submit a PR with the implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions