KeyVault API call error

Rahul 21 Reputation points

Hey, I was trying to make an api call using the endpoint of key vaults.
Here's my code:

def get_token():
    r ="",data={"grant_type": "client_credentials","client_secret": "xxxxx","client_id": "xxxxxxx","resource": ""})
    ret_body = r.json()
    return ret_body['access_token']

token = get_token()
headers = {'Authorization': 'Bearer ' + token}
conn = http.client.HTTPSConnection('')
conn.request("GET", '/subscriptions/xxxxxx/providers/Microsoft.KeyVault/vaults?api-version=2021-11-01-preview', "", headers)
response = conn.getresponse()
key_data =
key_data = key_data.decode('utf-8')
key_data = json.loads(key_data)

I haven't written the IDs here, but I have written it on my local code.

This call used to work always until I tried it out again today. This is the output I am getting
{'value': [], 'nextLink': '$skiptoken=ServiceBased,dGVzdHN0b3x0ZXN0dmF1bHQ2OTA='}

Again, I have removed the subscription while pasting it here. But I've mentioned what happens when I click the link below.

I tried changing the api versions too. Didn't work, I printed the header as well. Nothing was wrong. When I clicked on the "nextLink", this was the error I got.

{"error":{"code":"AuthenticationFailed","message":"Authentication failed. The 'Authorization' header is missing."}}

Is there something wrong with the code? Or has the endpoint somehow changed (highly unlikely)?

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,159 questions
{count} votes