Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Error 401 #260

Open
EinNiki opened this issue Nov 6, 2024 · 12 comments
Open

API Error 401 #260

EinNiki opened this issue Nov 6, 2024 · 12 comments

Comments

@EinNiki
Copy link

EinNiki commented Nov 6, 2024

Describe the bug
Cannot connect to API Error code 401

Environment Details (please complete the following information):

  • OS: [Debian 12 ]
  • Browser [Chrome]
  • Jellystat Version [1.1]
  • Jellyfin Version [10.10.1]

Screenshots
Screenshot 2024-11-06 180902

Container Logs
[JELLYSTAT] Server listening on http://127.0.0.1:3000Invalid token

@CyferShepard
Copy link
Owner

Hey @EinNiki , try logging out and back in, if you are on the login page but are receiving this error, try deleting the token in the local storage. Open your browsers developer tools, go to Application tab, and under local storage

@EinNiki
Copy link
Author

EinNiki commented Nov 6, 2024

I made a DashBoard where I use the Jellystat api

@CyferShepard
Copy link
Owner

Oh, are you using the api key in your authorization header? Can you provide an example of the api call you setup?

@EinNiki
Copy link
Author

EinNiki commented Nov 7, 2024

@CyferShepard
Copy link
Owner

seems like your using the api token as a bearer auth, it needs to be an api key auth, heres an example in postman.
image
image

@EinNiki
Copy link
Author

EinNiki commented Nov 10, 2024

https://haste.simplecloud.app/awafezuxuv.js
Did you mean it like that, if so then it still doesn't work

@CyferShepard
Copy link
Owner

your api endpoint doesn't look correct, you can reference the swagger docs for the correct endpoints at /swagger

@EinNiki
Copy link
Author

EinNiki commented Nov 14, 2024

curl -X POST "URL" -H "accept: application/json" -H "x-api-token: KEY" -H "Content-Type: application/json" -d "{\"username\": \"any\", \"password\": \"any\"}"

It still doesn't work (I still get "Unauthorized"). Do I have to have a username and password or not? Could you send me a curl or a code sample?

@Panda260
Copy link

hello?

@CyferShepard
Copy link
Owner

Hey @EinNiki , sorry, just been abit busy so havent had time to reply to issues.
Heres some examples. curl -X GET "/api/getLibraries" \ -H "X-API-Token: KEY" \ -H "Content-Type: application/json"

or curl -X POST "/stats/getLibraryItemsWithStats" \ -H "X-API-Token: KEY" \ -H "Content-Type: application/json" \ -d '{"libraryid": "your_library_id"}'

@Panda260
Copy link

curl -X GET "https://subdomain.maindomain.tld/api/getLibraries"
-H "X-API-Token: KEY-HERE"
-H "Content-Type: application/json"

works for me, I still had to adjust it a little.

@botagas
Copy link

botagas commented Jan 27, 2025

Hey @EinNiki , try logging out and back in, if you are on the login page but are receiving this error, try deleting the token in the local storage. Open your browsers developer tools, go to Application tab, and under local storage

Not directly related to the OP's situation, but to the error. I noticed that I have to clear browser cache almost every day to access Jellystat web UI without getting 401 errors. Deleting the session cookie also works, but you also have to do that often. Re-logging doesn't seem to do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants