mirror of
https://github.com/SillyTavern/SillyTavern-Extras.git
synced 2026-10-15 18:11:52 +00:00
[GH-ISSUE #79] GET 401 - Unauthorized API key access. #53
Labels
No labels
bug
duplicate
planned
pull-request
under consideration
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
SillyTavern/SillyTavern-Extras#53
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @viktorpetkov000 on GitHub (Jul 11, 2023).
Original GitHub issue: https://github.com/SillyTavern/SillyTavern-Extras/issues/79
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.
@Cohee1207 commented on GitHub (Jul 13, 2023):
How did you provide a key? You are trying to query the API directly or through SillyTavern app?
@viktorpetkov000 commented on GitHub (Jul 16, 2023):
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.
@Cohee1207 commented on GitHub (Jul 17, 2023):
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?

@viktorpetkov000 commented on GitHub (Jul 17, 2023):
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.
@viktorpetkov000 commented on GitHub (Jul 18, 2023):
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.