# How to authenticate users access token with public key from keyclock

**URL:** <https://forum.opensearch.org/t/how-to-authenticate-users-access-token-with-public-key-from-keyclock/7044>\
**Category:** Security\
**Created:** [September 17, 2021, 8:56am UTC](https://forum.opensearch.org/t/how-to-authenticate-users-access-token-with-public-key-from-keyclock/7044 "2021-09-17T08:56:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![disha27](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@disha27](https://forum.opensearch.org/u/disha27)\
**Post date:** [September 17, 2021, 8:56am UTC](https://forum.opensearch.org/t/how-to-authenticate-users-access-token-with-public-key-from-keyclock/7044/1 "2021-09-17T08:56:28Z")

</div>

I have configured JWT based backend authentication to use keyclock users in config.yml

public key I have used from Keyclock server-\> realmName-\>realm settings-\> keys → RS256 → public key

config.yml

```auto
jwt_auth_domain:
        http_enabled: true
        transport_enabled: true
        order: 0
        http_authenticator:
          type: jwt
          challenge: false
          config:
            signing_key: |-
              -----BEGIN PUBLIC KEY-----
              MIIBIjANBgk...
              -----END PUBLIC KEY-----
            jwt_header: "Authorization"
            jwt_url_parameters: "jwttoken"
            roles_key: "roles"
            subject_key: "sub"
            skip_users:
              - kibanaro
              - kibanaserver
              - logstash
              - admin
              - kibanauser
        authentication_backend:
          type: noop

```

kibana.yml

```auto
opendistro_security.auth.type: jwt
opendistro_security.jwt.url_param: jwttoken

```

I have created a token with API:  
/auth/realms/realmName/protocol/openid-connect/token

the created token is used for authenticating using curl command.  
curl -XGET [https://localhost:9200](https://localhost:9200) -H “Application-Authorization: Bearer $access-token-from-above-call” -k

but curl gives output as

```auto
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="Open Distro Security"
content-type: text/plain; charset=UTF-8
content-length: 12

```

I have doubt, it should used WWW-Authenticate: Bearer , but its showing WWW-Authenticate: Basic realm=''Open Distro Security"

What can be the issue with the above procedure?

---

<div class="post-metadata">

**Author:** ![disha27](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@disha27](https://forum.opensearch.org/u/disha27)\
**Post date:** [September 17, 2021, 9:19am UTC](https://forum.opensearch.org/t/how-to-authenticate-users-access-token-with-public-key-from-keyclock/7044/2 "2021-09-17T09:19:38Z")

</div>

It may help someone, My issue is solved by adding jwt\_token\_type: “Bearer” in config.yml  
below jwt\_header key in config section.

```auto
            jwt_header: "Authorization"
            jwt_token_type: "Bearer"
            jwt_url_parameters: "jwttoken"
            roles_key: "roles"
            subject_key: "sub"

```
