Skip to content

Conversation

philipithomas
Copy link
Contributor

Philip here from the Chroma team.

This SDK currently authenticates via a bearer token.

However, Chroma uses the x-chroma-token header instead of bearer, leading all authenticated requests with this SDK to fail with a 401 error. (Details in the Chroma OpenAPI spec: https://api.trychroma.com/docs/ )

I've patched the authentication method in this PR.

Signed-off-by: Philip I. Thomas <[email protected]>
@ilayaperumalg ilayaperumalg added this to the 1.1.0.M4 milestone Oct 8, 2025
@ilayaperumalg ilayaperumalg added the bug Something isn't working label Oct 8, 2025
@ilayaperumalg
Copy link
Member

@philipithomas Thanks for the PR!

@Kehrlann Could you review the changes please? Thanks!

@philipithomas
Copy link
Contributor Author

@Kehrlann Happy to help set up a free Chroma Cloud org for E2E testing, whether manual or automated - my email is philip at trychroma.com.

Copy link
Contributor

@Kehrlann Kehrlann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @philipithomas ! The fix seems correct.

[question] I'm a bit confused as to why the TokenSecuredChromaWhereIT does not fail with the current setup. Can you try it on your machine, and try to reproduce?
Is it because it's an outdated Chroma image?
It'd be good to have this correctly covered by tests.

[suggestion, non-blocking] One nice-to-have, good opportunity for a small refactoring. Instead of capturing the token in ChromApi#withToken, we do something similar to ChromaApi#withBasicAuthCredentials, something like:

public ChromaApi withKeyToken(String keyToken) {
	this.restClient = this.restClient.mutate()
			.defaultHeader(X_CHROMA_TOKEN, keyToken)
			.build();
	return this;
}

And we remove both the keyToken field and the httpHeader method.

private void httpHeaders(HttpHeaders headers) {
if (StringUtils.hasText(this.keyToken)) {
headers.setBearerAuth(this.keyToken);
headers.set("x-chroma-token", this.keyToken);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider putting x-chroma-token in a static field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working chromadb

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants