grafana / grafana-plugin-examples

189 stars 53 forks source link

Oauth example #127

Closed skiarn closed 1 year ago

skiarn commented 1 year ago

Hello,

I like an working example to understand how to add Add a OAuth 2.0 proxy route to your plugin

I forked and started an example here: https://github.com/skiarn/grafana-plugin-examples/tree/example/oauth/examples/datasource-http-oauth

Main changes see plugin.json: "routes": [ { "path": "api", "url": "{{ .JsonData.defaultUrl }}/v1", "headers": [ { "name": "Authorization", "content": "Bearer {{ .SecureJsonData.apiKey }}" } ] }, { "path": "api", "url": "{{ .JsonData.defaultUrl }}/v1", "tokenAuth": { "url": "{{ .JsonData.defaultUrl }}/token", "params": { "grant_type": "password", "username": "{{ .SecureJsonData.basicAuthUser }}", "password": "{{ .SecureJsonData.basicAuthPassword }}" } } } ]

How to make a working example? All I get is a 401 from remote server, how do I verify grafana managed to make an access_token exchange?

skiarn commented 1 year ago

"if you need to use a different grant than client credentials, you need to implement it yourself."

Does that mean Its not possible to write a plugin? A backend plugin is required?