Basic Auth API Call

Hi, I’m just a beginner on Grafana, I would like some example on how to use API to authenticate as Admin using Basic Auth through API call , and then create viewer users with another API call, not sure how should I pass user and password in request or If somehow I need to get a token first and then use it in subsecuent calls, If you could help me with an example of it that would be awsome,

Please Advise,

Hello,

If you want to use Basic Auth, you need to provide your username and password. The way of providing this information depends on the tool you are using to do the request. Here is an example using cURL (you can also leave the password blank and you will be prompted for the password)

curl --request POST 'http://localhost:3000/api/admin/users' --user "admin:admin" --header 'Content-Type: application/json' --data-raw '{"name":"test","email":"test","login":"test","password":"test"}'

If you search on Google the name of your tool and Basic Authentication, you should find more specific examples.

You have all the ways of authenticating to the API here. You can also use a session cookie (that you can retrieve with a login request) or an API Token (that you can generate through Grafana UI).

Maybe I should have started what I want to accomplish here, what I actually want is to embbed grafana dashboards into homemade application, so I need some how send credentials and not showing login page, I hope you can guide me in right direction.

Best Regards,