ryantxu / ajax-panel

Ajax Panel Plugin for Grafana
MIT License
156 stars 154 forks source link

Help with Bearer Token format #30

Open stulincoln opened 5 years ago

stulincoln commented 5 years ago

I am trying to use the Ajax component to call out to an API but am having issues with getting the header right for Bearer Token Auth. It should return a number but all I get is the full url as below.

Settings: Source: HTTP URL: https://myservice.com/service/core/v2/Users?count=true Method: GET Response: JSON Credentials: Off Only Changes: On Parameters: None (left blank) Headers: “Authorization”: “Bearer xxxxxxxxxxx” Display Mode: Direct HTML

This is the output -> {“err”:{“data”:null,“status”:-1,“config”:{“method”:“GET”,“transformRequest”:[null],“transformResponse”:[null],“jsonpCallbackParam”:“callback”,“responseType”:“json”,“url”:“https://myservice.com/service/core/v2/Users?count=true",“params”:{},“headers”:{“Authorization”:"Bearer xxxxxxxxxx”,“Accept”:“application/json, text/plain, /”},“cache”:false,“withCredentials”:false,“retry”:0},“statusText”:"",“xhrStatus”:“error”},“cancelled”:true}

Jacobh2 commented 5 years ago

I have a similar issue when trying to get a page from my webapp which uses basic auth

genuss commented 5 years ago

I've got same error with basic auth. Most certainly you forgot to add Access-Controll-* headers in response.

fpanwaskar commented 3 years ago

Hi,

I'm also trying to make a request passing on the current bearer token (retrieved from generic oauth). Is there a way to do this as a header?

I know this is supported for data sources. Is this possible via a panel? If so an example would be useful.

Thanks in advance.