From 1d814e482487be5c603c9cf5baa045d0e488a440 Mon Sep 17 00:00:00 2001 From: Trayan Azarov Date: Thu, 7 Sep 2023 18:50:10 +0300 Subject: [PATCH] docs: Added JS Client static token auth setup --- docs/usage-guide.md | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/docs/usage-guide.md b/docs/usage-guide.md index a0e62c5..67c3c6a 100644 --- a/docs/usage-guide.md +++ b/docs/usage-guide.md @@ -751,13 +751,13 @@ You can configure Chroma to use authentication when in server/client mode only. Supported authentication methods: -| Authentication Method | Basic Auth (Pre-emptive) | Static API Token | -|-----------------------|---------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------| -| 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 ` or in `X-Chroma-Token: ` headers.| -| Status | `Alpha` | `Alpha` | +| Authentication Method | Basic Auth (Pre-emptive) | Static API Token | +|-----------------------|---------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------| +| 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 ` or in `X-Chroma-Token: ` headers. | +| Status | `Alpha` | `Alpha` | | Server-Side Support | ✅ `Alpha` | ✅ `Alpha` | -| Client/Python | ✅ | ✅ | -| Client/JS | ✅ | ➖ | +| Client/Python | ✅ `Alpha` | ✅ `Alpha` | +| Client/JS | ✅ `Alpha` | ✅ `Alpha` | ### Basic Authentication @@ -868,8 +868,25 @@ client.list_collections() # this is a protected endpoint and requires authentic -:::info Not Available -Authentication is not yet supported in JS -::: +#### Client Setup + +Using the default `Authorization: Bearer ` header: + +```js +import { ChromaClient } from 'chromadb' + +const client = new ChromaClient({auth: {provider: "token", credentials: "test-token"}}); +//or explicitly specifying the auth header type +const client = new ChromaClient({auth: {provider: "token", credentials: "test-token", providerOptions: {headerType: "AUTHORIZATION"}}}); +``` + +Using custom Chroma auth token `X-Chroma-Token: ` header: + +```js +import { ChromaClient } from 'chromadb' + +const client = new ChromaClient({auth: {provider: "token", credentials: "test-token", providerOptions: {headerType: "X_CHROMA_TOKEN"}}}); +``` + \ No newline at end of file