As the architect says, you could retrieve a secret from Key Vault by Key Vault REST API instead of azure libraries.
GET https://{yourvault}.vault.azure.net/secrets?api-version=7.1
This API is used to list secrets in a specified key vault. And you could get a specified secret from a given key vault by this link.
First, get access_token with Post
via ApacheHttpClient
.
POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
client_id={your-client-id}
&scope=https%3A%2F%2Fvault.azure.net%2F.default
&client_secret={your-client-secret}
&grant_type=client_credentials
Then, call the REST API with Get
via ApacheHttpClient
.
GET https://{yourvault}.vault.azure.net/secrets?api-version=7.1
Authorization: Bearer {access_token}
I try this with Postman, and it works well. You could use httpclient to obtain secrets by java.

Note:
Navigate to Azure Portal > Key vaults > your_key_vault > Access policies > Add Access Policy. In secret permissions field, select desired permissions and Select Principal section, select the application that you are using to access the secret.