Forum Discussion

Ryan_'s avatar
Icon for Nimbostratus rankNimbostratus
May 10, 2023

Health Monitor using API token

I am checking a server using an API, using curl it succeeds but it takes two steps. First I request a bearer token by sending username and password, I then recieve a token valid for 300 seconds. I then pass that token to the api page and get a reponse with text I can match against for health monitoring. The API wont accept basic auth unfortunately.

I am a bit stuck as to how I can translate this into a health monitor though, if anyone can help it would be appreciated it. I presume I need an external monitor as there would be no way to pass the token as a variable to my post request right?

here is a basic overview from the cli I have trimmed outputs:


Get a token:

curl -k --request POST --url --data "grant_type=password&username=myusername&password=pass123"

repsonds with:

Send a second request
curl -kH "Authorization: Bearer 123mytoken123" ""

responds with: