I’m writing a datasource plugin with a backend component and everything is working fine.
I’d like to be able to edit the jsonData object of the datasource that will be persisted by Grafana. Either from the datasource class of the frontend or from the backend part. Can I do this?
Yes, if you inject the backendSrv service into your constructor then you have access to the Grafana api and can update the jsonData for the datasource.
You need to fetch the datasource first. Here is an example from the kubernetes app:
But can I also write to it? I don’t think I can edit it, right?
My specific use-case: I’m using a backend datasource plugin to deal with some non-standard OAuth authentication issue I’m having. I can’t use Grafana’s OAuth support because of some detail. Everything works great with my backend plugin but it would be great if it could store e.g. the refresh token in a secure way. But I don’t think this is possible for datasource backend plugins. Is this correct? Could I submit this as a feature request to the Github repository?