Closed viktorpetkov000 closed 1 year ago
How did you provide a key? You are trying to query the API directly or through SillyTavern app?
I use the API key that is generated when running the software with --secure. I tried querying through the SillyTavern app with no luck and then I tried querying directly with curl - still not luck. I tried also deleting the API key text file that is generated automatically and getting a new one - still no luck.
I tried it on my end (share and secure flags enabled), and everything appears to be working fine. Can you please confirm that you're running the latest versions for both pieces of software?
I'm running the Dev build for SillyTavern but I don't think that's the issue, since the API key generation is from extras, which I have updated and I tried querying the API key directly anyways. I tried with --listen enabled and disabled, no difference.
Okay, I've gone ahead and fixed the issue for myself. It turns out that the requests.authorization token was empty for some reason. I can't explain why, I tried querying many times with different headers and no luck. Finally I got sick of it and just changed the code to use request.headers.get('Authorization'), also adding a single "Bearer " prefix to it, instead of getattr(request.authorization, 'token', ''). Now it works perfectly.
The following is a curl command, trying to access the extras API with --share and --secure. Asterisks for privacy.
Using the API key provided with the correct API URL results in a 401 unauthorized api key error, both in the application and with external software. I'm not sure if I am doing something wrong or there is an issue with the API, however, I cannot successfully get --secure to work with --share, I'm forced to turn it off in order to access the api remotely.