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

Commit 1d814e4

Browse files
committed
docs: Added JS Client static token auth setup
1 parent 8d644ae commit 1d814e4

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

docs/usage-guide.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -751,13 +751,13 @@ You can configure Chroma to use authentication when in server/client mode only.
751751

752752
Supported authentication methods:
753753

754-
| Authentication Method | Basic Auth (Pre-emptive) | Static API Token |
755-
|-----------------------|---------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
756-
| Description | [RFC 7617](https://www.rfc-editor.org/rfc/rfc7617) Basic Auth with `user:password` base64-encoded `Authorization` header. | Static auth token in `Authorization: Bearer <tokem>` or in `X-Chroma-Token: <token>` headers.|
757-
| Status | `Alpha` | `Alpha` |
754+
| Authentication Method | Basic Auth (Pre-emptive) | Static API Token |
755+
|-----------------------|---------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|
756+
| Description | [RFC 7617](https://www.rfc-editor.org/rfc/rfc7617) Basic Auth with `user:password` base64-encoded `Authorization` header. | Static auth token in `Authorization: Bearer <tokem>` or in `X-Chroma-Token: <token>` headers. |
757+
| Status | `Alpha` | `Alpha` |
758758
| Server-Side Support |`Alpha` |`Alpha` |
759-
| Client/Python || |
760-
| Client/JS || |
759+
| Client/Python |`Alpha` |`Alpha` |
760+
| Client/JS |`Alpha` | `Alpha` |
761761

762762
### Basic Authentication
763763

@@ -868,8 +868,25 @@ client.list_collections() # this is a protected endpoint and requires authentic
868868
</TabItem>
869869
<TabItem value="js" label="JavaScript">
870870

871-
:::info Not Available
872-
Authentication is not yet supported in JS
873-
:::
871+
#### Client Setup
872+
873+
Using the default `Authorization: Bearer <token>` header:
874+
875+
```js
876+
import { ChromaClient } from 'chromadb'
877+
878+
const client = new ChromaClient({auth: {provider: "token", credentials: "test-token"}});
879+
//or explicitly specifying the auth header type
880+
const client = new ChromaClient({auth: {provider: "token", credentials: "test-token", providerOptions: {headerType: "AUTHORIZATION"}}});
881+
```
882+
883+
Using custom Chroma auth token `X-Chroma-Token: <token>` header:
884+
885+
```js
886+
import { ChromaClient } from 'chromadb'
887+
888+
const client = new ChromaClient({auth: {provider: "token", credentials: "test-token", providerOptions: {headerType: "X_CHROMA_TOKEN"}}});
889+
```
890+
874891
</TabItem>
875892
</Tabs>

0 commit comments

Comments
 (0)