API Authorization and Variables

Running Grafana 8.2.2

We are getting a new cloud based phone system and I’m looking at using Grafana to display Real-time call stats via API calls. I have tested this in Insomnia and Postman and have managed to get this working. The phone system isn’t currently live but I’m trying to get some options.

To get the stats I first need to make an API call to get an Access Token. In this API call it requires the following headers:
Content-Type = application/x-www-form-urlencoded
Authorization = Basic [Bearer token]

Then in the body I need to put:
grant_type = password
username = system generated client access token
password = system generated client secret

This then returns me the access_token with token_type “Bearer”

Once I have this, I can get the call stats.

When getting the call stats I have to set an Authorization Key with the Value of Bearer [previously acquired Access Token]. I currently set this within the custom http headers of the JSON API data source. If I set this manually then the stats are displayed correctly in a table using the JSON API. The issue I have is that the Bearer token changes every 60 minutes… and I have no way of changing that as it’s a system setting.

I’m trying to find a way to get the dashboard to automatically go off every 60 minutes, run the first api query that I currently have to run manually to get the Bearer access token and use that in the second call…

I apologise if I’ve missed anything as I’m new to Grafana.

Thanks.