samuelgja/elastic-tiny-client

Elasticsearch requires authentication/authorization to perform requests

Closed this issue · 5 comments

So I came across your library by accident and thankfully it all works as intended for my use case but I kept hitting the Elasticsearch error stating that it's missing some sort of authorization even though I put in the API key that is generated from their API.

It only worked with directly putting in a username/password combination as part of the config object. This is strange though because the Elasticsearch URL that I am using already contains the username and password as part of the URL :.

Do you think this could be due to Elasticsearch directly or the package?

Can you send your code what you are trying to do? I think some parts of authorizations can be missed in this package. But maybe its issue on elastic itself.

Did you use it like this:

    const client = new ElasticClient({
      hosts: ['http://localhost:9200'],
      authorization: { password: 'yourElasticPassword', username: 'elastic' },
    })
const client = new ElasticClient({
    hosts: [ELASTICSEARCH_URL],
    authorization: {
      username: ELASTICSEARCH_USERNAME,
      password: ELASTICSEARCH_PASSWORD,
    },
  });

Yep. It would be cool to support urls with credentials within it like so:

const client = new ElasticClient({
    hosts: https://<user>:<password>@<company>.io,
  });

I added support for it here: #2

Thanks!