Nextcloud polls app API issue by logout hook


I’m trying to work with the API for polls app but I’ve been getting this particular error:

{"error":"invalid_grant_and_session","error_description":"The provided access token and session state are invalid or were issued to another client.","reason":"Failed to identify session by session_id query parameter or by session_id cookie."}

Whenever I call API routes such as “” with basic auth.

I’m using a custom SSO app that has a logout hook which sends a request to the SSO oidc server to log the user out of that when they log out of Nextcloud.

When I disable this app or remove the logout hook, the API call returns a response with expected content (e.g a list of my polls).

I’m not sure why this userManager “postLogout” event my hook is listening to is even called during this API call or if something else if happening, but it seems whenever the logout hook is present it causes this issue.

Any clues to why this behaviour is happening or how to resolve it? I can provide more info but I’m not sure what will help.