# Pass access token received from http\_poller call to http filter

**URL:** https://discuss.elastic.co/t/pass-access-token-received-from-http-poller-call-to-http-filter/287225
**Category:** Logstash
**Created:** [October 20, 2021, 5:14pm UTC](https://discuss.elastic.co/t/pass-access-token-received-from-http-poller-call-to-http-filter/287225 "2021-10-20T17:14:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![byoungman](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@byoungman](https://discuss.elastic.co/u/byoungman)
#### Post date: [October 20, 2021, 5:14pm UTC](https://discuss.elastic.co/t/pass-access-token-received-from-http-poller-call-to-http-filter/287225/1 "2021-10-20T17:14:17Z")

</div>

I am able to successfully get an access token from the http\_poller plugin but now I need to pass that token on to the http filter in order to make my REST call.

I'm assuming that I need to do this through the headers field in the http filter such as

headers =\> ["Authorization", "Bearer xxxx-token from http\_poller"] but not sure how to this dynamically so that it uses the token from the http\_poller plugin.

New to these two plugins so any help / direction is greatly appreciated.

My access token is being returned in the access\_token field from the http\_poller plugin and my http filter is configured like this

```auto
		http {
			body_format => "json"
			follow_redirects => false
			body => {
				"attribute" => "%{[attribute_value]}"
			}
			url => REST API URL
			verb => "GET"
			headers => ["Authorization", "Bearer %{access_token}"]
			target_body => "[@metadata][api_response]"
			target_headers => "[@metadata][api_headers]" 
		}

```

Pretty sure that I have the 'headers' section set up wrong but was trying to get a starting point.

Thanks,  
Bill

---

<div class="post-metadata">

### Author: ![ptamba](https://avatars.discourse-cdn.com/v4/letter/p/7feea3/32.png) [@ptamba](https://discuss.elastic.co/u/ptamba)
#### Post date: [October 21, 2021, 5:36pm UTC](https://discuss.elastic.co/t/pass-access-token-received-from-http-poller-call-to-http-filter/287225/2 "2021-10-21T17:36:41Z")

</div>

haven’t had experience with this, but the docs said that headers should be hash so have you tried

```auto
headers => {
  “Authorization” => “Bearer %{access_token}”
}

```

---

<div class="post-metadata">

### Author: ![byoungman](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@byoungman](https://discuss.elastic.co/u/byoungman)
#### Post date: [October 22, 2021, 1:25pm UTC](https://discuss.elastic.co/t/pass-access-token-received-from-http-poller-call-to-http-filter/287225/3 "2021-10-22T13:25:48Z")

</div>

This worked like a charm - thank you

Now I'm on to seeing why my metric data is being injected into the target\_body field and I think it has something to do with this - I think it's set incorrectly

target\_body =\> "[@metadata][api\_response]"

Thanks,  
Bill

---

<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: [November 19, 2021, 1:25pm UTC](https://discuss.elastic.co/t/pass-access-token-received-from-http-poller-call-to-http-filter/287225/4 "2021-11-19T13:25:59Z")

</div>

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