Unable to access dashboard API

  • What Grafana version and what operating system are you using?
    Latest, Mac.

  • What are you trying to achieve?
    Accessing the dashboard API.

  • How are you trying to achieve it?
    Making a fetch request from express app

  • What happened?
    I am receiving a 401 unauthorized response.

  • What did you expect to happen?
    I created a service account token that never expires, and i expected to receive access.

  • Can you copy/paste the configuration(s) that you are having problems with?

grafanaRouter.get(‘/tags’, async (req, res) => {
console.log(‘Inside grafanaRouter’);
try {
const response = await fetch(‘http://grafana.staged-by-discourse.com/?orgId=1/dashboards/tags’, {
method: ‘GET’,
headers: {
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’,
‘Authorization’: ‘Bearer sa-front-dc4671a0-1827-4758-8f86-317b5d8ca6ae’,
},
});

if (response.ok) {
  const data = await response.json();
  res.json(data);
} else {
  console.error('Failed to fetch tags:', response.status, response.statusText);
  res.sendStatus(500);
}

} catch (error) {
console.error(‘Error:’, error);
res.sendStatus(500);
}
});

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    The response I receive is, Failed to fetch tags: 401 Unauthorized.

  • Did you follow any online instructions? If so, what is the URL?
    I followed the the API Dashboard docs