Splunk AppDynamics

unable to get token via api https://accountName.saas.appdynamics.com/controller/api/oauth/access_token

Tran_Vinh1
Explorer

I follow up on this doc to generate tokens via API but I didn't receive any response from the server.
https://docs.appdynamics.com/appd/4.5.x/en/extend-appdynamics/appdynamics-apis/api-clients#APIClient...
the curl like below:

curl -X POST -H "Content-Type: application/vnd.appd.cntrl+protobuf;v=1" "https://(accountName).saas.appdynamics.com/controller/api/oauth/access_token" -d 'grant_type=client_credentials&client_id=(username)@(accountName)&client_secret=(clientsecret)'
Please help me!



Labels (3)
0 Karma
1 Solution

zhouyaoji
Path Finder

@Tran.Vinh, I spoke to our engineer again, and his last suggestion was to make sure your client secret was correct as well, even if that means generating a new one. If that doesn't work, please go to https://help.appdynamics.com/hc/en-us/requests and file a ticket, so our customer support team will look into it. I'd also make sure that the client name and account name don't have any trailing spaces. I hope regenerating a client secret helps, but if not, I'm sorry I couldn't help you.

View solution in original post

0 Karma

iamryan
Community Manager
Community Manager

Hi @Tran.Vinh , @sunil.vanmullem 

Can you offer any help to Clarence based on your experience with this?

0 Karma

zhouyaoji
Path Finder

@Tran.Vinh , the engineer wants to confirm  that you are using the correct parameters for the `client_id` parameter. Can you verify that `Waverley%20Software%20Inc` is your account name and that `readyapi` is your API client name? Since you are not getting an HTTP 500 error, in other words, it doesn't appear to be a syntax issue, that the authorization 401 error might be caused by incorrect credentials---at least that's what we're trying to determine.

0 Karma

Tran_Vinh1
Explorer

Hi @Joe.Catera 
I attached the image of the account name and client_name in some pictures below. Please help me check on the issue 401
Thanks
image.png

image.png

0 Karma

zhouyaoji
Path Finder

@Tran.Vinh, I spoke to our engineer again, and his last suggestion was to make sure your client secret was correct as well, even if that means generating a new one. If that doesn't work, please go to https://help.appdynamics.com/hc/en-us/requests and file a ticket, so our customer support team will look into it. I'd also make sure that the client name and account name don't have any trailing spaces. I hope regenerating a client secret helps, but if not, I'm sorry I couldn't help you.

0 Karma

Tran_Vinh1
Explorer

@Joe.Catera 
It worked well after I got support from the customer support team.
Thank you so much.

0 Karma

Clarence_Perry
New Member

I know this is an older post, but we are experiencing the same issue, and are using the same curl statement parameters.  What did the support team do to correct the issue for you?

0 Karma

Morelz
Builder
Hi Clarence, what Content-Type are you using in the headers?

With the latest release of the Controller, there is a specific Content-Type you need to use, not the protobuf one like always 🙂
0 Karma

Kuba_Siemiatkow
New Member

I'm having the same issue and it started happening a few days ago. The CURL command from the docs still throws 401.

0 Karma

Morelz
Builder

Update your Content-Type to this and it will work again, it is mentioned in the release notes of the last Controller Update - 

{"Content-Type": "application/x-www-form-urlencoded"}
0 Karma

Kuba_Siemiatkow
New Member

As I said, the CURL command from the docs doesn't work. It already has a content-type header: https://docs.appdynamics.com/appd/24.x/24.12/en/extend-cisco-appdynamics/cisco-appdynamics-apis/api-...

Not even mentioning there's two different commands in the example, one with basic auth added. I've tried all combinations of my username, domain, API client and still getting 401.

$ curl -i -X POST -H "Content-Type: application/x-www-form-urlencoded" "https://mothership2019052316285110.saas.appdynamics.com/controller/api/oauth/access_token" \
-d 'grant_type=client_credentials&client_id=EnterpriseTest@mothership2019052316285110&client_secret=<secret>'
HTTP/1.1 401 Unauthorized
Content-Type: text/html; charset=UTF-8
Content-Length: 204
Connection: keep-alive
x-frame-options: SAMEORIGIN
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
cache-control: must-revalidate,no-cache,no-store
last-modified: Tue, 28 Jan 2025 08:17:18 GMT
accept-ranges: bytes
x-envoy-upstream-service-time: 13
date: Mon, 03 Feb 2025 22:38:47 GMT
server: istio-envoy
x-envoy-decorator-operation: pdx-p-con-437-svc.pdx-p-con-437.svc.cluster.local:8079/*

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Unauthorized</title>
</head>
<body>
HTTP Error 401 Unauthorized
<p/>
This request requires HTTP authentication
</body>
</html>%



image.png

0 Karma

Morelz
Builder

Hi, is this a production instance or a trial?

I just used your exact curl command, and updated with my values and it works. Don't see an issue with the Command.

I believe there is a limitation on using the API if using a trial, but if it is not a trial, you need to contact AppD Support to have a look at your controller to see what the issue is.

0 Karma

Kuba_Siemiatkow
New Member

No it's not a trial. But it was working correctly so why would AppD devs ship out a breaking change without notifying us ? We haven't touched the controller in months

0 Karma

open768
Path Finder

Hi Tran.vinh, if you would like another example of how to get a token using an API secret, i'm doing the following on my rapport application: (https://github.com/open768/appdinc/blob/main/auth.php its in php, but hopefully you get the gist)

the querystring i use is

$oHttp->request_payload =
			"grant_type=client_credentials&" .
			"client_id=$app@$account&" .
			"client_secret=$api_secret";

with extra headers:

$oHttp->extra_headers = ["Content-Type" => "application/vnd.appd.cntrl+protobuf;v=1"];

 then do a GET request to the API for your controller  "/api/oauth/access_token"

this returns the access token to use for the API.

HTH 🙂

zhouyaoji
Path Finder

Hi @Tran.Vinh ,

You're using docs that are four years old. The request header has changed since 4.5 (the latest docs are 23.x), so the request should be the following:

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" "https://<controller address>/controller/api/oauth/access_token" -d 'grant_type=client_credentials&client_id=<apiClientName>@<accountName>&client_secret=<clientSecret>'

See https://docs.appdynamics.com/appd/23.x/latest/en/extend-appdynamics/appdynamics-apis/api-clients.

The request header is now the following:

Content-Type: application/x-www-form-urlencoded"

 I've been told that you should be able to use the Controller REST APIs with a trial license, BTW. 

0 Karma

Tran_Vinh1
Explorer

Hi @Joe.Catera 
I tried sending a request flow your latest doc but I still have a new issue with 401 unauthorized

image.png

curl -i -X POST -H "Content-Type: application/x-www-form-urlencoded" -u "readyapi:683dfd51-60ea-4224-adc2-557e8d2212a0" "https://walker202302080517089.saas.appdynamics.com/controller/api/oauth/access_token" -d 'grant_type=client_credentials&client_id=readyapi@Waverley%20Software%20Inc&client_secret=683dfd51-60ea-4224-adc2-557e8d2212a0'
Could you help me check and correct if my syntax invalid
Thanks

0 Karma

zhouyaoji
Path Finder

Hi @Tran.Vinh ,

I'm not seeing anything wrong with your command syntax but am getting an "HTTP 401 Unauthorized" error. I'm asking one of our engineers to take a look to see if your command syntax is correct or if it's a credential issue. I'll get back to you next week with his response.

Tran_Vinh1
Explorer

@Joe.Catera 
Do you have any update?

0 Karma

zhouyaoji
Path Finder

@Tran.Vinh , I asked an engineer to help in a support ticket, but I haven't heard back, so I wrote to the engineer directly. Sorry about the delay.

0 Karma

iamryan
Community Manager
Community Manager

Hi @Tran.Vinh,

I was asked to pass this along.

Can you please run this command with "curl -i" or verbose? It would be interesting to know if the server considers it a bad request or unauthorized.

0 Karma

Tester_Testerso
New Member

Hi @Ryan.Paredez 
image.png

this is the result. I saw an internal server error with error code 500

0 Karma
Get Updates on the Splunk Community!

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco &#43; Splunk! We’ve ...

AI Adoption Hub Launch | Curated Resources to Get Started with AI in Splunk

Hey Splunk Practitioners and AI Enthusiasts! It’s no secret (or surprise) that AI is at the forefront of ...