Unable to download kibana csv report using access token

I am trying to access kibana csv report using the reporting api /api/reporting/jobs/download/{jobId}. I am able to get the data using basic authentication in my api using username and password. However when i make request using oauth2 authentication using apikey in my request I am getting the following error
{ "statusCode": 403, "error": "Forbidden", "message": "Ask your administrator for access to reporting features." }

can someone please help me with this? Is this some api key permission issue?

Welcome!

Is the user the same one? I mean with the exact same roles?

yes, I created the api key from the app/management/api_keys from the ui. still getting unauthenticated error

What is your version?

8.16

Thanks.

I'm able to reproduce it.
And while I was looking at the github repository, I found this issue:

So I guess this will come in the future.

Note that if you are trying to export a CSV from discover, you might be able to do this using ES|QL with ?format=csv.

That's limited in the number of extracted rows but that might help you.

thanks for the help!