API Key for service admin

From the issues listed below, I can understand I can not simply use api key to call /api/org endpoints but the examples given in this link http://docs.grafana.org/http_api/org/ are using “Bearer” token as example and confuses me.

Is the doc needed for update? If api key is not supported for server admin, why the doc uses Bearer token?



Are there any specific routes that are not working? Some routes are restricted to not work with api keys - for example changing the Grafana Admin password. Most of the org routes require that the user is an organization admin.

These worked for me when using a key for a user that is an org admin:

curl  -H "Authorization: Bearer eyJrestofmykey" http://grafana.staged-by-discourse.com/api/org
curl  -H "Authorization: Bearer eyJrestofmykey" http://grafana.staged-by-discourse.com/api/org/users

Thank you for the information.

Path such as api/orgs using Bearer token doesn’t seem to work. When the documentation (copied below) suggests it should (http://docs.grafana.org/http_api/org/). Or I am missing something?

Organisations
Search all Organisations

GET /api/orgs

Example Request:

GET /api/orgs HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

No, you are correct. The documentation is wrong for all routes under /api/orgs. /api/org routes work with an API key.

You will have to use Basic Auth:

curl http://admin:admin@community.grafana.com/api/orgs

I’ll fix the documentation. Thanks for reporting it and saving future pain for other users!

thanks for confirming. I was able to use basic auth without problems.

Hii,

I am trying to search all the organisation using curl http://admin:admin@community.grafana.com/api/orgs but I am getting {“message”:“Permission denied”} response though username and password is correct. I am using grafana 3.0

Thank you,