dclient/docs/authentication.md
Simon Willison c847badc4e
dclient insert command (#13)
* Move making queries to own page, refs #7
* Documentation for the dclient insert feature, refs #8
* Implemented progress bar for insert, refs #8
* --pk option
* --ignore and --replace for insert, refs #8
* --batch-size option, refs #8
* First insert test, using a mock - refs #8
* insert test that exercises against an in-memory Datasette instance, refs #8
* Insert tests now cover an error case, refs #8
* Tests for --ignore and --replace, refs #8
* Tests for different formats, refs #8
* Test for --no-detect-types
* Support for --encoding, refs #8
2023-07-24 16:22:39 -07:00

2.7 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/

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

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

Options:
  --help  Show this message and exit.