Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client Creation does not Apply Supplied API Key to ApiKey Header #2592

Open
ronaldroe opened this issue Jan 31, 2025 · 1 comment
Open

Client Creation does not Apply Supplied API Key to ApiKey Header #2592

ronaldroe opened this issue Jan 31, 2025 · 1 comment

Comments

@ronaldroe
Copy link

ronaldroe commented Jan 31, 2025

🐛 Bug report

This is my client declaration:

const client = new Client(
    {
      node: '***',
      auth: {
        apiKey: {
          api_key: '***',
          id: '***'
        }
      },
      requestTimeout: 120000,
      maxRetries: 10
    }
  );

Request header has no API key in that header:

header: {
          'WWW-Authenticate': [
            'Basic realm="security" charset="UTF-8"',
            'Bearer realm="security"',
            'ApiKey'
          ]
        }

Error output:

root_cause: [
          {
            type: 'security_exception',
            reason: 'missing authentication credentials for REST request [//_search]',
            header: [Object]
          }
        ]

I created the key and copied it directly. I've tried both with and without the id. The key never gets added to the header for some reason, and I didn't find anything about it in the docs other than the structure above, which I pasted directly from the docs. I get the same error when I try username/password

To reproduce

Use an input with what the docs show is a properly formed ApiKey

Expected behavior

The api key authenticates the user

Node.js version

20.12

@elastic/elasticsearch version

6.3

Operating system

MacOS

Any other relevant environment information

No response

@JoshMock
Copy link
Member

JoshMock commented Feb 3, 2025

@ronaldroe As far as I'm aware, there is no Elasticsearch client with version 6.3, even in the old client that was deprecated a few years ago. Could you verify what version you are actually using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants