Add custom HTTP header in JSON Datasource dynamically

Hi there!

I want to add a custom HTTP header dynamically. I have my own app authentication witch needs to use this JSON Datasource. In front of Grafana, I am using a reverse proxy(Nginx).

  1. User login in the app and backend send JWT token to the frontend.
    2 User can auto-login Grafana by clicking a particular button and will be redirected with the JWT token from my backed attached in the URL(e.g. http://localhost:8900/dashboards?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c ).

I want to add this token in the custom HTTP header and Grafana to send it with every request. I am able to do this by hardcoding the header in Nginx(e.g proxy_set_header X-User-custom “XXXX” ), but it works only this way.

I am stuck in this for a while and will appreciate any help.

1 Like