The error message is quite clear, Request is missing a Bearar or Pop token
.
Steps to create the token:
- create a service principal using this command -
az ad sp create-for-rbac
grab appId
from the output command and provide permissions to this service principal :
- Grab
password
, appId
and tenant
from the above command and replace with the following:
curl --location --request POST 'https://login.microsoftonline.com/{TenantID}/oauth2/v2.0/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id={appId}' \
--data-urlencode 'client_secret={password}' \
--data-urlencode 'scope=https://vault.azure.net/.default'
Get access_token from the responding command and pass it to this command:
curl -s "https://test-poc-kv-
31.vault.azure.net/keys/sftp/ec8368364d1844c908234396e8f50344e68?api-version=7.1" -H
"Authorization: Bearer %access_token%"
instead of using curl, you can use Azure CLI ( and make your life much easier ) :
az keyvault key show --name "%KEY_NAME%" --vault-name "VAULT_NAME"