Developing Datasource Plugin with Grafana Proxy and API that requires authentication

I am developing a Grafana plugin using ToolKit to retrieve data from the AWS API (AWS support).

  • HTTP access mode cannot use Browser due to CORS problem, so I have to use Server side (GrafanaProxy).
  • At first, I thought that there was a problem in creating the Authorization header for requesting to the AWS API, so I tested it with a simple request js code, but since I was able to get the data from AWS Support, I think that there is no problem in the Authorization Header creation process.

So I am investigating the internal processing of grafanaproxy when sending a request to the data source.

source code

await getBackendSrv().datasourceRequest({
url: this.url,
method: 'POST',
headers: options.headers,
data: options.body,
});

error details

status: 400
statusText: "Bad Request"
data: {__type: "SerializationException"}
proto: Object

1.When making a request through grafanaproxy, I think that the following processing is performed in the authentication header. Is this wrong?

  • Converts the Authorization header to the X-DS-Authoraization header to avoid duplication with Grafana’s headers.
  • Convert X-DS-Authoraizaiton header to Authorization header for the API from Grafana Proxy.

2.If you know what to look out for when sending a request to the AWS API, please let me know.

I guessed from #5c8fef8 and “public/app/core/services/backend_srv.tss” why I thought this way.