Jump to content

401 Errors on Attempted Deletes


Recommended Posts

Posted

I'm running a script that deletes watched recordings.  Was working forever now it fails to delete any recordings with a 401 error.  The user running the script is an admin user in emby and has full permissions to delete any content.  I've verified from the client side that the token is being sent on each api call.  HTTP GET calls succeed with the token, but the HTTP DELETE calls to delete media fail with a 401.  I'm guessing a recent update may be the cause?  I'm running 4.7.11.0.  I also enabled debug logging on the server and there's nothing notable.  I just see this:

2023-02-25 13:04:57.198 Info Server: http/1.1 POST http://192.168.44.80:8096/Users/AuthenticateByName. Accept=application/json, Connection=keep-alive, Host=192.168.44.80:8096, Authorization=Emby UserId="steve", Client="EmbySweeper", Device="EmbySweeper", DeviceId="EmbySweeper", Version="2.0.2", Content-Type=application/json, Content-Length=36
2023-02-25 13:04:57.201 Debug AuthenticationRepository: GetInternalId reportedDeviceId: EmbySweeper
2023-02-25 13:04:57.230 Info UserManager: Authentication request for steve has succeeded.
2023-02-25 13:04:57.231 Info SessionManager: Reissuing access token: 3612eae538e549b9ab68350ec1f2e958
2023-02-25 13:04:57.232 Debug AuthenticationRepository: GetCapabilities id: 6
2023-02-25 13:04:57.256 Info Server: http/1.1 Response 200 to host3. Time: 57ms. http://192.168.44.80:8096/Users/AuthenticateByName
2023-02-25 13:04:57.279 Debug Server: http/1.1 GET http://192.168.44.80:8096/Users. UserAgent: 
2023-02-25 13:04:57.294 Debug XmlSerializer: Deserializing file /var/lib/emby/config/users/0395320e458f4774b3a38632109cbac7/config.xml
2023-02-25 13:04:57.294 Debug XmlSerializer: Deserializing file /var/lib/emby/config/users/ab662e5448ba4c7c86f175a890ac3a01/config.xml
2023-02-25 13:04:57.294 Debug XmlSerializer: Deserializing file /var/lib/emby/config/users/d8431e2862294cfbbecc6f0dc796b6a2/config.xml
2023-02-25 13:04:57.295 Debug Server: http/1.1 Response 200 to host3. Time: 15ms. http://192.168.44.80:8096/Users
2023-02-25 13:04:57.306 Debug Server: http/1.1 GET http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Views. UserAgent: 
2023-02-25 13:04:57.307 Debug Server: http/1.1 Response 200 to host3. Time: 1ms. http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Views
2023-02-25 13:04:57.320 Debug Server: http/1.1 GET http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?parentId=34297&recursive=true&Fields=Path&IsPlayed=true&IsFavorite=false. UserAgent: 
2023-02-25 13:04:57.340 Debug Server: http/1.1 Response 200 to host3. Time: 20ms. http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?parentId=34297&recursive=true&Fields=Path&IsPlayed=true&IsFavorite=false
2023-02-25 13:04:57.350 Debug Server: http/1.1 GET http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?Ids=45925. UserAgent: 
2023-02-25 13:04:57.358 Debug Server: http/1.1 Response 200 to host3. Time: 8ms. http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?Ids=45925
2023-02-25 13:04:57.370 Debug Server: http/1.1 GET http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?Ids=45810. UserAgent: 
2023-02-25 13:04:57.371 Debug Server: http/1.1 Response 200 to host3. Time: 1ms. http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?Ids=45810
2023-02-25 13:04:57.378 Debug Server: http/1.1 GET http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?Ids=45664. UserAgent: 
2023-02-25 13:04:57.379 Debug Server: http/1.1 Response 200 to host3. Time: 1ms. http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?Ids=45664
2023-02-25 13:04:57.390 Debug Server: http/1.1 GET http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?Ids=46044. UserAgent: 
2023-02-25 13:04:57.391 Debug Server: http/1.1 Response 200 to host3. Time: 1ms. http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?Ids=46044
2023-02-25 13:04:57.396 Debug Server: http/1.1 GET http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?Ids=45942. UserAgent: 
2023-02-25 13:04:57.397 Debug Server: http/1.1 Response 200 to host3. Time: 1ms. http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?Ids=45942
2023-02-25 13:04:57.405 Debug Server: http/1.1 GET http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?Ids=45894. UserAgent: 
2023-02-25 13:04:57.405 Debug Server: http/1.1 Response 200 to host3. Time: 1ms. http://192.168.44.80:8096/Users/fa218b51ecac41c2bcfa12f77f256c51/Items?Ids=45894
2023-02-25 13:04:57.428 Info Server: http/1.1 DELETE http://192.168.44.80:8096/Items/45937. UserAgent: 
2023-02-25 13:04:57.431 Error Server: Unauthorized access
2023-02-25 13:04:57.431 Info Server: http/1.1 Response 401 to host3. Time: 3ms. http://192.168.44.80:8096/Items/45937
2023-02-25 13:04:57.464 Info Server: http/1.1 DELETE http://192.168.44.80:8096/Items/45922. UserAgent: 
2023-02-25 13:04:57.464 Error Server: Unauthorized access
2023-02-25 13:04:57.465 Info Server: http/1.1 Response 401 to host3. Time: 1ms. http://192.168.44.80:8096/Items/45922
2023-02-25 13:04:57.475 Info Server: http/1.1 DELETE http://192.168.44.80:8096/Items/45962. UserAgent: 
2023-02-25 13:04:57.476 Error Server: Unauthorized access
2023-02-25 13:04:57.476 Info Server: http/1.1 Response 401 to host3. Time: 0ms. http://192.168.44.80:8096/Items/45962
2023-02-25 13:04:57.492 Info Server: http/1.1 DELETE http://192.168.44.80:8096/Items/45909. UserAgent: 
2023-02-25 13:04:57.492 Error Server: Unauthorized access
2023-02-25 13:04:57.492 Info Server: http/1.1 Response 401 to host3. Time: 0ms. http://192.168.44.80:8096/Items/45909

 

Posted

Hi, is this with an API key that you generated?

Posted

No, I'm first calling `AuthenticateByName` and using the returned token from that call in all other api calls.  Can't use generated api keys, I don't believe, because they aren't tied to a user and so can never delete media files.

Posted

Are you able to delete using the emby web app when logged in with the same user?

  • 3 weeks later...
Posted

Have you compared your http request to what the web app is doing by using the browser debugger?

Posted

Next time it starts erroring out again I will.  But now -- out of the blue -- the script is able to delete files again.  Nothing has changed other than Emby has been restarted once or twice to upgrade plugins.  It's almost like something goes stale after awhile and an Emby restart gets things working again.

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...