I’m building a datasource plugin and use routes in my plugin.json to define the API endpoint with a tokenAuth section describing OAuth authentication.
This is not working because Grafana expects the answer for an authentication to for example list the refresh token as “refresh_token” whereas my endpoint returns “refreshToken”. What can I do?
I agree, it’s non-standard. Unfortunately I have no influence over it, it’s a proprietary API. That’s why we can’t have nice things, I guess. Or can I?
We don’t have a way to configure the names of the oauth fields.
It is possible to do it another way but it will be a lot of extra work. We recently added a new hook to Grafana that allows you to have a backend component (written in Go) in your datasource. You can authenticate however you want on the backend - so you could copy the relevant Go code from Grafana into your backend component and tweak it.
The Stackdriver datasource sort of does some custom auth:
And this is the code in Grafana that does auth for plugin routes and handles refresh tokens (and which Stackdriver calls manually):
We use a library for oauth which expects refresh_token so one way to do it would be to provide your own access token implementation and translate refreshToken to refresh_token: