dclient/docs/authentication.md
Claude 02dd3ae9ca
Update documentation for new commands and output formats
- Update README.md with new commands summary and uv development workflow
- Add docs/exploring.md covering databases, tables, schema, rows, get
  commands with filtering, sorting, pagination, and output format examples
- Add docs/writing.md covering create-table, upsert, update, delete, drop
- Update docs/queries.md with output format options (--csv, --tsv, --nl, --table)
- Update docs/inserting.md with cross-references to upsert/update
- Update docs/index.md toctree to include new pages
- Regenerate all cog --help blocks with current command signatures

https://claude.ai/code/session_01DoiJf9Gbvbw2asN9yvP6dx
2026-02-12 01:28:52 +00:00

3.6 KiB

(authentication)=

Authentication

dclient can handle API tokens for Datasette instances that require authentication.

You can pass an API token to query using -t/--token like this:

dclient query https://latest.datasette.io/fixtures "select * from facetable" -t dstok_mytoken

A more convenient way to handle this is to store tokens to be used with different URL prefixes.

Using stored tokens

To always use dstok_mytoken for any URL on the https://latest.datasette.io/ instance you can run this:

dclient auth add https://latest.datasette.io/

Then paste in the token and hit enter when prompted to do so.

To list which URLs you have set tokens for, run the auth list command:

dclient auth list

To delete the token for a specific URL, run auth remove:

dclient auth remove https://latest.datasette.io/

Testing a token

The dclient actor command can be used to test a token, retrieving the actor that the token represents.

dclient actor https://latest.datasette.io/content

The output looks like this:

{
    "actor": {
        "id": "root",
        "token": "dstok"
    }
}

dclient auth --help

Usage: dclient auth [OPTIONS] COMMAND [ARGS]...

  Manage authentication for different instances

Options:
  --help  Show this message and exit.

Commands:
  add     Add an authentication token for an alias or URL
  list    List stored API tokens
  remove  Remove the API token for an alias or URL

dclient auth add --help

Usage: dclient auth add [OPTIONS] ALIAS_OR_URL

  Add an authentication token for an alias or URL

  Example usage:

      dclient auth add https://datasette.io/content

  Paste in the token when prompted.

Options:
  --token TEXT
  --help        Show this message and exit.

dclient auth list --help

Usage: dclient auth list [OPTIONS]

  List stored API tokens

  Example usage:

      dclient auth list

Options:
  --help  Show this message and exit.

dclient auth remove --help

Usage: dclient auth remove [OPTIONS] ALIAS_OR_URL

  Remove the API token for an alias or URL

  Example usage:

      dclient auth remove https://datasette.io/content

Options:
  --help  Show this message and exit.

dclient actor --help

Usage: dclient actor [OPTIONS] [URL_OR_ALIAS]

  Show the actor represented by an API token

  Example usage:

      dclient actor https://latest.datasette.io/fixtures

Options:
  --token TEXT  API token
  --help        Show this message and exit.