Hit OCS endpoints with a keycloak token

Nextcloud version (eg, 29.0.5): 29
Operating system and version (eg, Ubuntu 24.04): 24.04
Apache or nginx version (eg, Apache 2.4.25): 2.4.25
PHP version (eg, 8.3): 8.3

The issue you are facing:

I try to hit an OCS endpoint, but I use a KeyCloak auth. Social Login is installed and configured. It works when I use the NC_SESSION_ID as a token with “Authorization: Bearer”, but this variable is supposed to be httponly.

When I use the KC JWT, I get {"ocs":{"meta":{"status":"failure","statuscode":997,"message":"Current user is not logged in"},"data":[]}}.

When I use the NC_SESSION_ID, it returns the json it’s supposed to return.

How can I use my Keycloak JWT to perform these queries ? Or convert a JWT into a NC_SESSION_ID ?

The OCS endpoint is : /ocs/v2.php/search/providers/mail/search?term=%20&format=json

Thanks.