diff --git a/docs/sources/developers/plugins/add-authentication-for-data-source-plugins.md b/docs/sources/developers/plugins/add-authentication-for-data-source-plugins.md index 829220f4408..aac94865702 100644 --- a/docs/sources/developers/plugins/add-authentication-for-data-source-plugins.md +++ b/docs/sources/developers/plugins/add-authentication-for-data-source-plugins.md @@ -291,7 +291,7 @@ To allow Grafana to pass the access token to the plugin, update the data source When configured, Grafana can forward authorization HTTP headers such as `Authorization` or `X-ID-Token` to a backend data source. This information is available across the `QueryData`, `CallResource` and `CheckHealth` requests. -To get Grafana to forward the headers, create a HTTP client using the [Grafana Plugin SDK](https://pkg.go.dev/github.com/grafana/grafana-plugin-sdk-go/backend/httpclient). This package exposes request information which can be subsequently forwarded downstream and/or used directly within the plugin. +To get Grafana to forward the headers, create a HTTP client using the [Grafana plugin SDK for Go](https://pkg.go.dev/github.com/grafana/grafana-plugin-sdk-go/backend/httpclient) and set the `ForwardHTTPHeaders` option to `true` (by default, it's set to `false`). This package exposes request information which can be subsequently forwarded downstream and/or used directly within the plugin. ```go func NewDatasource(settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) { @@ -299,6 +299,9 @@ func NewDatasource(settings backend.DataSourceInstanceSettings) (instancemgmt.In if err != nil { return nil, fmt.Errorf("http client options: %w", err) } + + opts.ForwardHTTPHeaders = true + // Important to reuse the same client for each query, to avoid using all available connections on a host cl, err := httpclient.New(opts) if err != nil {