Hello!
My Grafana version is v9.0.3 (023f9251a9).
I am developing a datasource plugin which should use oauth authentication when making a rest api call.
I successfully configured SSO for Grafana login. Now I need to use the user under whom I authenticated to Grafana to make a request from my datasource.
According to the documentation (Add authentication for data source plugins | Grafana documentation), I need to add these lines to my plugin.json file for routes:
"tokenAuth": {
"url": "https://api.example.com/v1/oauth/token",
"params": {
"grant_type": "client_credentials",
"client_id": "{{ .SecureJsonData.clientId }}",
"client_secret": "{{ .SecureJsonData.clientSecret }}"
}
}
I added the lines. Then when I request my endpoint with backendSrv method, the url which I provided for tokenAuth is called and the parameters which I passed in the params attribute also are passed. But the problem is that I also need to pass one more parameter which is the code which was received when the user authenticated in Grafana itself. I am not sure how to get this code that is why the oauth/token endpoint returns an error.
Could somebody let me know how this oauth flow should work? Because I believe that if I do not pass the code which was received during SSO authentication to Grafana itself, it will never work.
Thank you!