How create access token to use administration rest api

Hi to all, I’ve to call some keycloak Administration Rest API.

to call the api I need a valid bearer token;
at now I use a call similar to this:

curl -X POST \
  https://<HOST>/auth/realms/master/protocol/openid-connect/token \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'cache-control: no-cache' \
  -d 'grant_type=password&username=<USERNAME>l&password=<PASSWORD>&client_id=admin-cli'

I retrieve the token and I spend it on my api rest.
It works but I’m wondering if there is a more elegant and safe way to retrieve the access token without share with the application, that will use the api, the admin username and password.

I’ve try to use a client-id/secret, I retrieve the token but when I use it to access to api i’m not authorized…