grafana / grafana-infinity-datasource

CSV, JSON, GraphQL, XML and HTML datasource for grafana.
https://grafana.com/docs/plugins/yesoreyeram-infinity-datasource
Apache License 2.0
765 stars 103 forks source link

[Bug] Azure Function authentication with function key ends up in: error getting data frame. 401 Unauthorized #963

Closed alukyan closed 2 months ago

alukyan commented 3 months ago

Describe the bug

I have an Azure function that accepts one parameter and returns a simple JSON output. When I configure the data source I specify "API Key Value pair" and provide Azure function key as "Query Parameter" that is Key=code; Value=<Function key value>.

When I test my new data source I specify my Azure function URL

https://<myfunction>.azurewebsites.net/api/MyFunction?param=foo-bar

I am getting error getting data frame. 401 Unauthorized image

In Grafana's Query Inspector I can see that my URL is represented correctly as

###############
## URL
###############

https://<myfunction>.azurewebsites.net/api/MyFunction?param=foo-bar&code=xxxxxxxx

with function key obfuscated by "xxxxxx". However, I am getting "401".

When I go back to reconfigure the Infinity data source with "No Auth" and specify the function key right in the query as

https://<myfunction>.azurewebsites.net/api/MyFunction?param=foo-bar&code=<function key value>

Then everything works. When I look at the Query Inspector then I see my URL is represented correctly as above but without obfuscation of the function key.

It appears there is an issue of how Grafana saves the data source authentication parameters and passes them to the queries.

I tried using Headers instead of Query parameters in the Auth section. I also tried to pass function key in "Headers & URL params" section with the same results.

Steps to reproduce

Sample Data

Screenshots

Version Details:

Additional context

Add any other context about the problem here.

alukyan commented 2 months ago

I figured this out - this was my mistake with back-and-forth URL encoding with some characters in the function key