# Problem using http\_poller to get access token from AppDynamics OAUTH API

**URL:** https://discuss.elastic.co/t/problem-using-http-poller-to-get-access-token-from-appdynamics-oauth-api/287006
**Category:** Logstash
**Created:** [October 18, 2021, 2:50pm UTC](https://discuss.elastic.co/t/problem-using-http-poller-to-get-access-token-from-appdynamics-oauth-api/287006 "2021-10-18T14:50:22Z")
**Posts on this page:** 3
**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 18, 2021, 2:50pm UTC](https://discuss.elastic.co/t/problem-using-http-poller-to-get-access-token-from-appdynamics-oauth-api/287006/1 "2021-10-18T14:50:23Z")

</div>

I am using the http\_poller input filter to get an outh access token from AppDynamics that I will then use to pass to the http filter plugin to retrieve AppDynamics REST API metric data to insert into Elasticsearch.

My logstash http\_poller configuration is:

```auto
input {
	http_poller {
		urls => {
			AppDynamics => {
				method => post
				url => "https://*appdynamics-test-account*/controller/api/oauth/access_token"
				headers => {
					"Accept" => "application/json"
					"Content-Type" => "application/vnd.appd.cntrl+protobuf;v=1"
					"Authorizations" => "*AppDynamics bearer token*"
					"grant_type" => "client_credentials"
					"client_id" => "Stage-CurlTest"
					"client_secret" => "*AppDynamics Client Secret*"
				}
			}
		}
		request_timeout => 60
		schedule => { every => "1h"}
		codec => "json"
		metadata_target => "appd-token"
		type => "AppDynamics"
	}
}
}

```

I am getting the following error response when the poller tries to connect to AppDynamics

```auto
{
	"type": "AppDynamics",
	"@timestamp": "2021-10-18T14:02:11.191Z",
	"appd-token": {
		"request": {
			"method": "post",
			"url": "https://*appdynamics-test-account*/controller/api/oauth/access_token",
			"headers": {
				"Authorizations": "AppDynamics Bearer Token",
				"grant_type": "client_credentials",
				"client_secret": "`AppDynamics Client Secret`",
				"client_id": "Stage-CurlTest",
				"Content-Type": "application/vnd.appd.cntrl+protobuf;v=1",
				"Accept": "application/json"
			}
		},
		"response_headers": {
			"x-content-type-options": "nosniff",
			"x-frame-options": "SAMEORIGIN",
			"x-xss-protection": "1; mode=block",
			"connection": "keep-alive",
			"server": "AppDynamics",
			"date": "Mon, 18 Oct 2021 14:02:10 GMT"
		},
		"runtime_seconds": 0.36,
		"host": "SAPPLOG03",
		"name": "AppDynamics",
		"response_message": "Not Acceptable",
		"code": 406,
		"times_retried": 0
	},
	"@version": "1",
	"tags": [
		"_httprequestfailure"
	]
}

```

New to both the http\_poller filter and the AppDynamics Metric REST API so not sure what I have configured wrong. I'm also going to post this in the AppDynamics Support forum.

Thanks,  
Bill

---

<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, 7:58pm UTC](https://discuss.elastic.co/t/problem-using-http-poller-to-get-access-token-from-appdynamics-oauth-api/287006/2 "2021-10-20T19:58:17Z")

</div>

Was able to get my http\_poller plugin returning an access token with the following configuration

```auto
	http_poller {
		urls => {
			AppDynamics => {
				method => post
				url => "https://vertex-test.saas.appdynamics.com/controller/api/oauth/access_token"
				body => "grant_type=client_credentials&client_id=xxxx@vertex-test&client_secret=xxxx"
				headers => {
					"Content-Type" => "application/vnd.appd.cntrl+protobuf;v=1"
				}
			}
		}
		request_timeout => 60
		schedule => { every => "15m"}
		codec => "json"
		metadata_target => "appd-token"
		type => "AppDynamics"
	}

```

But now I am getting an invalid access token error when the http filter plugin fires - this is the config for that

```auto
		http {
			body_format => "json"
			follow_redirects => false
			url => "https://xxxx.saas.appdynamics.com/controller/rest/applications/Vertex%20Cloud%20%28Stage%29/metric-data?metric-path=Application%20Infrastructure%20Performance%7COSP%20Servers%7CIndividual%20Nodes%7CSOSESB01%7CJVM%7CMemory%7CHeap%7CCurrent%20Usage%20%28MB%29&time-range-type=BEFORE_NOW&duration-in-mins=60"
			verb => "GET"
			headers => ["Authorization", "Bearer %{appd-token}"]
			target_body => "[@metadata][api_response]"
			target_headers => "[@metadata][api_headers]" 
		}

```

I am following the sample given by Yassine Lasri in this post [Http\_poller REST API authentication token](https://discuss.elastic.co/t/http-poller-rest-api-authentication-token/246870/5)

Getting closer...

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 17, 2021, 7:58pm UTC](https://discuss.elastic.co/t/problem-using-http-poller-to-get-access-token-from-appdynamics-oauth-api/287006/3 "2021-11-17T19:58:23Z")

</div>

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