Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

feat: Added python examples for both transport headers for token auth #243

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions docs/usage-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -886,20 +886,35 @@ export CHROMA_AUTH_TOKEN_TRANSPORT_HEADER="X_CHROMA_TOKEN"

#### Client Setup

Using the default `Authorization: Bearer <token>` header:

```python
import chromadb
from chromadb.config import Settings

from chromadb.auth.token_authn import TokenTransportHeader
client = chromadb.HttpClient(
settings=Settings(chroma_client_auth_provider="chromadb.auth.token_authn.TokenAuthClientProvider",
chroma_client_auth_credentials="test-token"))
chroma_client_auth_credentials="test-token",
chroma_auth_token_transport_header=TokenTransportHeader.AUTHORIZATION, # this can also be omitted as it is the default. Alternatively use "Authorization" as string value
))
client.heartbeat() # this should work with or without authentication - it is a public endpoint

client.get_version() # this should work with or without authentication - it is a public endpoint

client.list_collections() # this is a protected endpoint and requires authentication
```

Using custom Chroma auth token `X-Chroma-Token: <token>` header:

```python
import chromadb
from chromadb.config import Settings
from chromadb.auth.token_authn import TokenTransportHeader
client = chromadb.HttpClient(
settings=Settings(chroma_client_auth_provider="chromadb.auth.token_authn.TokenAuthClientProvider",
chroma_client_auth_credentials="test-token",
chroma_auth_token_transport_header=TokenTransportHeader.X_CHROMA_TOKEN, # Alternatively "X-Chroma-Token" as string value
))
```

</TabItem>
<TabItem value="js" label="JavaScript">

Expand Down