How to get the API key from REST API or other scripts?

In this page http://docs.grafana.org/http_api/auth/
we could create our admin auth API KEY,
but this operation is manually done,
Can we use a REST API to perform this? To get a API KEY?
OR though other cmd using my admin username/password?

I want to make this process more automatically, thanks.

you have have to use basic auth and then use the API to generate an api token.

So, is there any function for me to use and I can post my admin username and password to that url?

1 Like

An example with curl using basic auth:

curl -X POST -H "Content-Type: application/json" -d '{
  "name": "mykey",
  "role": "Admin"
}' http://admin:youradminpassword@localhost:3000/api/auth/keys
2 Likes

Thanks, it works!:slight_smile: