Jump to content

Access token is invalid of expired on Delete using my API_Key


Go to solution Solved by Brazer,

Recommended Posts

Posted

Hi all

I am trying to delete a collection via the API using my generated API key. I am getting a 401. Why?

2024-04-23 01:21:38.435 Info Server: http/1.1 DELETE https://host1:8920/emby/Items/Delete=3748005&api_key=_secret_. UserAgent: python-requests/2.31.0
2024-04-23 01:21:38.450 Warn Server: AUTH-ERROR: 188.74.100.63 - Access token is invalid or expired.
2024-04-23 01:21:38.450 Error Server: Access token is invalid or expired.
2024-04-23 01:21:38.450 Info Server: http/1.1 Response 401 to host4. Time: 15ms. DELETE https://host1:8920/emby/Items/Delete=3748005&api_key=_secret_
 

Posted

Hi, what version of the server? I just tested deleting a collection in the web app and it worked just fine.

Posted

@LukeVersion 4.9.0.13 beta

All the other calls work. It is just the delete. 

Posted

OK please attach the emby server log from when that happened. Thanks.

Posted

Forgive me for hijacking the thread, as I have also been trying to get the DELETE call to work (v4.8.5).

It seems to execute successfully from Swagger and produces the following URL:

https://emby.FQDN.redacted/emby/Items/405542?api_key=[redacted]

However, when I try to perform it locally, substituting the API key with the one I have produced in the Dashboard, I get the following error out of the server, complaining that the "user" parameter cannot be null. Where am I going wrong? I have tried adding in the ?userId parameter, as well as just ?user but it doesn't resolve the problem.

2024-04-30 22:55:31.522 Info Server: http/1.1 DELETE http://‌‍‍emby.FQDN.redacted/Items/405688?api_key=‌e16bfdd4c29b4ba8bd54f334f4721afd‌. UserAgent: python-requests/2.31.0
2024-04-30 22:55:31.523 Debug SqliteItemRepository: GetitemById Episode 405688 /mnt/emby/TV/[filename]
2024-04-30 22:55:31.523 Error Server: Error processing request
        *** Error Report ***
        Version: 4.8.5.0
        Command line: /opt/emby-server/system/EmbyServer.dll -programdata /var/lib/emby -ffdetect /opt/emby-server/bin/ffdetect -ffmpeg /opt/emby-server/bin/ffmpeg -ffprobe /opt/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{version}_amd64.deb
        Operating system: Linux version 5.15.0-101-generic (buildd@lcy02-amd64-032) (gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #111-Ubun
        Framework: .NET 6.0.25
        OS/Process: x64/x64
        Runtime: opt/emby-server/system/System.Private.CoreLib.dll
        Processor count: 2
        Data path: /var/lib/emby
        Application path: /opt/emby-server/system
        System.ArgumentNullException: System.ArgumentNullException: Value cannot be null. (Parameter 'user')
           at MediaBrowser.Controller.Entities.BaseItem.GetShareLevel(User user)
           at Emby.Api.Library.LibraryService.Any(DeleteItems request)
           at Emby.Api.Library.LibraryService.Any(DeleteItem request)
           at Emby.Server.Implementations.Services.ServiceController.<>c__DisplayClass8_0.<VoidActionDelegate>b__0(Object service, Object request)
           at Emby.Server.Implementations.Services.ServiceController.Execute(HttpListenerHost appHost, Object requestDto, IRequest req, Type serviceType)
           at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost httpHost, IServerApplicationHost appHost, IRequest httpReq, IResponse httpRes, IStreamHelper streamHelper, RestPath restPath, String responseContentType, CancellationToken cancellationToken)
           at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, ReadOnlyMemory`1 urlString, ReadOnlyMemory`1 localPath, CancellationToken cancellationToken)
        Source: MediaBrowser.Controller
        TargetSite: MediaBrowser.Model.Dto.UserItemShareLevel GetShareLevel(MediaBrowser.Controller.Entities.User)
 

pünktchen
Posted
8 hours ago, artstar said:

2024-04-30 22:55:31.522 Info Server: http/1.1 DELETE http://‌‍‍emby.FQDN.redacted/Items/405688?api_key=‌e16bfdd4c29b4ba8bd54f334f4721afd‌. UserAgent: python-requests/2.31.0
2024-04-30 22:55:31.523 Debug SqliteItemRepository: GetitemById Episode 405688 /mnt/emby/TV/[filename]
2024-04-30 22:55:31.523 Error Server: Error processing request

Your python request is missing "emby" between your FQDN and Items.

Posted
1 hour ago, pünktchen said:

Your python request is missing "emby" between your FQDN and Items.

My fault for not mentioning that I tried it both with and without 'emby' in it. Both yield the same result.

pünktchen
Posted
3 hours ago, artstar said:

My fault for not mentioning that I tried it both with and without 'emby' in it. Both yield the same result.

You need "emby", but probably also the user end point that is mentioned in the other thread that you've posted in.

artstar
Posted
8 hours ago, pünktchen said:

You need "emby", but probably also the user end point that is mentioned in the other thread that you've posted in.

Appreciate it. Trying to figure out what that user endpoint is, given I copy and paste the cURL command that's created by Swagger. Swagger executes the API call just fine but copy and paste of the cURL command (for execution locally) fails in exactly the same way as described. Anyway, I'll cease with the rude double-posting. I didn't realise amateurgod had already been discussing this until after I posted in this thread. Seems more appropriate to continue the conversation there.

Posted

Hi, we'll take a look at it. Thanks.

  • Like 1
  • 4 weeks later...
Posted
On 23/04/2024 at 23:19, Luke said:

OK please attach the emby server log from when that happened. Thanks.

@LukeAs requested. 

embyserver.txt

  • Solution
Posted

@LukeI found the problem. My url was incorrect. 
It was:
/emby/Items/Delete=3752149&api_key=b50f1b30613e416e80e11368ce1eca00
Should be:
/emby/Items/3752149?api_key=b50f1b30613e416e80e11368ce1eca00

  • Disagree 1
artstar
Posted
24 minutes ago, Brazer said:

@LukeI found the problem. My url was incorrect. 
It was:
/emby/Items/Delete=3752149&api_key=b50f1b30613e416e80e11368ce1eca00
Should be:
/emby/Items/3752149?api_key=b50f1b30613e416e80e11368ce1eca00

So your beta version is successfully removing the entry and deleting the file?

Posted
50 minutes ago, artstar said:

So your beta version is successfully removing the entry and deleting the file?

Yes it did. 

artstar
Posted (edited)
3 minutes ago, Brazer said:

Yes it did. 

That's good news. Given you're beta testing, it sounds like Luke and his team have found the solution to the problem, and I just need to wait for the next general release. :)

Edited by artstar
Posted
4 minutes ago, artstar said:

That's good news. Given you're beta testing, it sounds like Luke and his team have found the solution to the problem, and I just need to wait for the next general release. :)

I don't know if it was broken. There was a bug in my code.

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...