# Unable to login via oidc azure

**URL:** <https://discuss.elastic.co/t/unable-to-login-via-oidc-azure/238582>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [June 25, 2020, 1:23am UTC](https://discuss.elastic.co/t/unable-to-login-via-oidc-azure/238582 "2020-06-25T01:23:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![clonelab](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/clonelab/32/49699_2.png) [@clonelab](https://discuss.elastic.co/u/clonelab)\
**Post date:** [June 25, 2020, 1:23am UTC](https://discuss.elastic.co/t/unable-to-login-via-oidc-azure/238582/1 "2020-06-25T01:23:01Z")

</div>

Hi,

I am having an issue with azuread oidc authentication to my elasticsearch. It works well but when it required to /api/security/v1/oidc? with the code it seems to have an issue and displays this error in the UI.

```auto
{"statusCode":401,"error":"Unauthorized","message":"[security_exception] unable to authenticate user [<OIDC Token>] for action [cluster:admin/xpack/security/oidc/authenticate], with { header={ WWW-Authenticate={ 0=\"Bearer realm=\\\"security\\\"\" & 1=\"Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\" } } }"}

```

This is the error log in OIDC:

```auto
{"type": "server", "timestamp": "2020-06-25T01:15:51,030Z", "level": "WARN", "component": "o.e.x.s.a.AuthenticationService", "cluster.name": "elasticsearch", "node.name": "elastic", "message": "Authentication to realm cloud-oidc failed - Failed to authenticate user with OpenID Connect (Caused by ElasticsearchSecurityException[Failed to consume the OpenID connect response.]; nested: IllegalArgumentException[HTTP host may not be null];)", "cluster.uuid": "my8XX0AYQS-z-yPK1-pe8A", "node.id": "9aSo2VMES4-v_DN-Y4oQRw" }

```

I have a very basic elastic config also:

```auto
    network.host: 0.0.0.0

    xpack.security.enabled: true
    xpack.security.authc.token.enabled: true
    xpack.security.http.ssl.enabled: false

    xpack:
      security:
    authc:
      realms:
        native.realm1:
            order: 0
        oidc:
          cloud-oidc:
            order: 2
            rp.client_id: "removed"
            rp.response_type: code
            rp.redirect_uri: "http://localhost:5601/api/security/v1/oidc"
            op.issuer: "https://login.microsoftonline.com/removedv2.0"
            op.authorization_endpoint: "https://login.microsoftonline.com/removed/oauth2/v2.0/authorize"
            op.token_endpoint: "token_endpoint"
            op.jwkset_path: "https://login.microsoftonline.com/removed/discovery/v2.0/keys"
            op.userinfo_endpoint: "https://graph.microsoft.com/oidc/userinfo"
            op.endsession_endpoint: "https://login.microsoftonline.com/removed/oauth2/v2.0/logout"
            rp.post_logout_redirect_uri: "http://localhost:5601/logged_out"
            claims.principal: sub

```

I am using elasticsearch container 7.8

---

<div class="post-metadata">

**Author:** ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)\
**Post date:** [June 25, 2020, 4:11am UTC](https://discuss.elastic.co/t/unable-to-login-via-oidc-azure/238582/2 "2020-06-25T04:11:26Z")

</div>

Change

```auto
op.token_endpoint: "token_endpoint"

```

to the url of the actual endpoint

---

<div class="post-metadata">

**Author:** ![clonelab](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/clonelab/32/49699_2.png) [@clonelab](https://discuss.elastic.co/u/clonelab)\
**Post date:** [June 25, 2020, 6:35am UTC](https://discuss.elastic.co/t/unable-to-login-via-oidc-azure/238582/3 "2020-06-25T06:35:13Z")

</div>

Thank you that resolved the error. Such as rookie move sorry about that.

---

<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:** [July 23, 2020, 6:35am UTC](https://discuss.elastic.co/t/unable-to-login-via-oidc-azure/238582/4 "2020-07-23T06:35:16Z")

</div>

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