Hubfly spaceDocs
Console

CLI Authentication & Identity

The Hubfly space CLI utilizes secure bearer token authentication. Tokens authorize all REST API calls, container deployments, log streams, and SSH sessions.

Authentication System Overview

When you execute any CLI operation, ensureAuth() inspects local storage at ~/.hubfly/config.json or checks the HUBFLY_TOKEN environment variable.

If no valid session is found in an interactive terminal, the CLI guides you through browser authentication or prompts for a Personal Access Token (PAT). In non-interactive environments, it raises an explicit authentication required error.

hubfly login

Authenticates your local terminal with your Hubfly space account.

SyntaxFlagsDescription
hubfly login--token <TOKEN>Generates or saves an API bearer token locally to ~/.hubfly/config.json.

Interactive Browser Login

In an interactive terminal, running hubfly login displays your authentication link:

terminal

$ hubfly login
Please authenticate to continue. Go to https://dashboard.hubfly.space/cli/auth to get the token
Enter your API token: hf_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
Successfully logged in as Ada Lovelace (ada@analytical.dev)

Personal Access Tokens & Headless CI

For scripted environments or GitHub Actions where interactive prompts cannot run, pass your token directly with --token or set the HUBFLY_TOKEN environment variable:

terminal

$ hubfly login --token hf_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
Successfully logged in as Ada Lovelace (ada@analytical.dev)

GitHub Actions Example

name: Deploy App
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install Hubfly space CLI
        run: curl -fsSL https://raw.githubusercontent.com/hubfly-space/hubfly-cli/main/install.sh | bash
      - name: Deploy
        env:
          HUBFLY_TOKEN: ${{ secrets.HUBFLY_TOKEN }}
        run: hubfly deploy --project my-api --region eu-west-1 --yes

hubfly whoami

Validates your stored token against GET /api/v1/auth/me and prints identity details:

terminal

$ hubfly whoami
Logged in as Ada Lovelace (ada@analytical.dev)

hubfly logout

Removes the stored token from ~/.hubfly/config.json and terminates local CLI session state:

terminal

$ hubfly logout
Logged out successfully.

API Error Codes & Backend Trace IDs

When an API call returns an HTTP error code (for example 401, 403 or 500), the CLI parses the JSON error response and surfaces its request/error trace identifier when one is available:

terminal

$ hubfly whoami
Authentication required (status 401, trace err_91f82b7c01a)

Provide the trace ID (for example err_91f82b7c01a) to support. The CLI also maps common failures to exit codes so CI can distinguish authentication, conflict, timeout and usage errors.

Token Security

Keep your Personal Access Tokens secure. CLI tokens carry full project deployment and execution scope. Never commit raw tokens to public Git repositories.
Something unclear or out of date? Emailsupport@hubfly.spaceBack to top