Unable to connect via token through the API

Hello ElasticSearch community,

I'm using google cloud functions as backend and using a simple angular HttpClient to connect via the API to my google cloud elasticsearch endpoint.

At first when I tried to connect I got some CORS policies problems but was able to sole them adding

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers : Authorization, X-Requested-With,X-Auth-Token,Content-Type, Content-Length 

to my instance yaml config file

now I've made this code:

host = 'https://c...9e.us-east1.gcp.elastic-cloud.com:9243/_search'
const token = btoa(`${my_id}:${my_token}`);
const options = {
  headers: {
    'Authorization': `ApiKey ` + token
  },
  params: {
    q: '*4*'
  }
}
this.http.get(this.host, options).subscribe(
  (response) => {
    console.log(response)
  }
)

and get a 401 error code.

I've also tried to change xpack.security.authc.api_key.enabled to true but I get

Elasticsearch - 'xpack.security.authc.api_key.enabled': is not allowed

I don't really understand what is xpack or on which instance I should exactly put this line but I've tried putting it everywhere i could.

I'm using free trial of entrerprise search

Many thanks in advance

The problem was that the chosen role to create the API key had insufficient privileges