#community-help

Troubleshooting Local Authentication Issue in Typesense

TLDR Todd reported consistent issues with local authentication, leading to requests failing. Kishore Nallan suggested checking the server logs. This revealed Todd was using an incorrect API key. The issue resolved by itself, although somewhat mysteriously.

Powered by Struct AI

1

6
1mo
Solved
Join the chat
Oct 05, 2023 (1 month ago)
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
10:03 PM
Hey all, is anyone else having issues with local authentication lately? All of the sudden, all of my requests fail with:

RequestUnauthorized: Request failed with HTTP code 401 | Server said: Forbidden - a valid `x-typesense-api-key` header must be sent.

I’m confused, I’m on the latest stable docker image 0.25.1, and the latest version of the nodejs client 1.7.1. I’ve tried pruning my docker images and recreating my data volume. Nothing seems to help however. I’m setting the bootstrap api key via the TYPESENSE_API_KEY environment variable and just using that.

Anyone else having this issue, or anyone got any tips for further troubleshooting?
Oct 06, 2023 (1 month ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:06 AM
Try checking the server logs to see if any error is logged when request fails
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
12:40 AM
Kishore Nallan - Okay, so I did that, and this is definitely the smoking gun there:

Scoped API keys can only be used for searches.

However, I’m confused. I’m not manually creating API keys anywhere locally, and I’m just using the bootstrap API key, which I supply to the docker container as the TYPESENSE_API_KEY environment variable
12:41
Todd
12:41 AM
Also, thank you for the quick and helpful response!
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:59 AM
The code checks for bootstrap api key first and then checks for stored api keys and finally for scoped api key. So it seems like somehow you are passing the wrong key and it doesn't match bootstrap api key so it ends up in the code path that leads to this error.
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
02:48 AM
Kishore Nallan - Hrm. Okay, I was working on a demo reproduction and then my original codebase stopped having issues. I have no idea what happened there, but all I need is to be unjammed really, so I’m good again. Thank you for your help and sorry to spend your time on my confusion.

1