First, run following commands in shell, please replace placeholder according to your environment:
export CLIENT_ID=<client id>
export CLIENT_SECRET=<client secret>
export TOKEN_EP=https://accounts.cloud.databricks.com/oidc/accounts/<databricks account id>/v1/token
then run this command to generate token:
curl --request POST --url $TOKEN_EP --user "$CLIENT_ID:$CLIENT_SECRET" --data 'grant_type=client_credentials&scope=all-apis'
Please make sure you follow following instructions to create client id/secret for your service principal, it should be created at account level instead of workspace level.
https://docs.databricks.com/en/dev-tools/auth/oauth-m2m.html#step-3-create-an-oauth-secret-for-a-ser...