# Bearer token in HTTP filter

**URL:** <https://discuss.elastic.co/t/bearer-token-in-http-filter/284641>\
**Category:** Logstash\
**Created:** [September 20, 2021, 5:03pm UTC](https://discuss.elastic.co/t/bearer-token-in-http-filter/284641 "2021-09-20T17:03:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Montoya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/juan_montoya/32/83579_2.png) [@Juan\_Montoya](https://discuss.elastic.co/u/Juan_Montoya)\
**Post date:** [September 20, 2021, 5:03pm UTC](https://discuss.elastic.co/t/bearer-token-in-http-filter/284641/1 "2021-09-20T17:03:53Z")

</div>

Hi,

I'm trying to get data from an HTTP API, the main API needs a bearer token to authenticate, a secondary API gives me the token that allows the authentication in the main API. I Solved using _http\_poller input_ to get the token and then use _HTTP filter_ to get the important data. But I can't find a way to use a bearer token in _HTTP filter_. This is my pipeline:

```auto
input {
    http_poller {
        urls => {
            getToken => {
                method => post
                body => '{"username":"myusername", "password":"mypassword"}'
                url => "http://myhost/rest-api/authenticate"
                headers => {
                    Accept => "*/*"
                    "Content-Type" => "application/json"
                }
            }
        }
        request_timeout => 60
        schedule => {
            cron => "* * * * * UTC"
        }
        metadata_target => "http_poller_metadata"
    }
}

filter {
    http {
        url => "http://myhost/rest-api/topology"
        verb => "POST"
        body => "ELKnode"
        body_format => "json"
        target_body => "fieldata"
        authorization => "%{token}"

    }
}

output {
    stdout {
        codec => json {
        }
    }
}

```

How can I give the bearer token to the _HTTP filter_? or If there is a better way to do this please tell me

Thanks

---

<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:** [October 18, 2021, 5:04pm UTC](https://discuss.elastic.co/t/bearer-token-in-http-filter/284641/2 "2021-10-18T17:04:22Z")

</div>

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