# Trouble authenticating with API Keys and the .Net Client Elasticsearch.Extensions.Logging

**URL:** <https://discuss.elastic.co/t/trouble-authenticating-with-api-keys-and-the-net-client-elasticsearch-extensions-logging/288392>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [November 4, 2021, 8:38am UTC](https://discuss.elastic.co/t/trouble-authenticating-with-api-keys-and-the-net-client-elasticsearch-extensions-logging/288392 "2021-11-04T08:38:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajuch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ajuch/32/96708_2.png) [@ajuch](https://discuss.elastic.co/u/ajuch)\
**Post date:** [November 4, 2021, 8:38am UTC](https://discuss.elastic.co/t/trouble-authenticating-with-api-keys-and-the-net-client-elasticsearch-extensions-logging/288392/1 "2021-11-04T08:38:17Z")

</div>

Hi,

I'm having a hard time getting log data from an aspnet core application into an elastic cloud instance. I created an API Key in Kibana and passed the Base64 encoded variant of the API Key and the Cloud ID to the .AddElasticCloud method.

Since neither logs appeared in ES nor any error is displayed in the aspnet core application, I used fiddler to debug the issue. It shows the error "missing authentication credentials for REST request" and returns a 401 error.

 ![elastic-cloud-auth](https://us1.discourse-cdn.com/elastic/original/3X/a/e/aec598eb0427023546a4c1f14fc5de5bb867a534.png)

I'd be glad for any hints!

Best regards, Andreas

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [November 15, 2021, 8:37am UTC](https://discuss.elastic.co/t/trouble-authenticating-with-api-keys-and-the-net-client-elasticsearch-extensions-logging/288392/2 "2021-11-15T08:37:36Z")

</div>

Hi @ajuch,

This looks like a bug; Elastic.Transport is incorrectly sending the `Bearer` scheme when the scheme should be `ApiKey`

> <https://github.com/elastic/elastic-transport-net/blob/7b32264ac6e2ae781b7ce431d07b7bb2e37b00e9/src/Elastic.Transport/Configuration/Security/ApiKey.cs#L23-L24>

I'll open an issue for this. In the meantime, as a workaround, you'd be able to username and password with the logging extension.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 13, 2021, 8:37am UTC](https://discuss.elastic.co/t/trouble-authenticating-with-api-keys-and-the-net-client-elasticsearch-extensions-logging/288392/3 "2021-12-13T08:37:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
