我正在尝试使用 python sdk 从 azure keyvault 检索和打印机密列表。
下面返回一个 paged.SecretItemPaged 对象:
from azure.keyvault import KeyVaultClient, KeyVaultAuthentication
from azure.common.credentials import ServicePrincipalCredentials
az_client_id = '*****'
az_secret = '*****'
az_tenant = '*****'
credentials = None
def auth_callback(server, resource, scope):
credentials = ServicePrincipalCredentials(
client_id=az_client_id,
secret=az_secret,
tenant=az_tenant,
resource="https://vault.azure.net"
)
token = credentials.token
return token['token_type'], token['access_token']
client = KeyVaultClient(KeyVaultAuthentication(auth_callback))
secrets = client.get_secrets('https://thevault.vault.azure.net/')
print('vault secrets:\n{}'.format(secrets))
例如:
vault secrets:
<azure.keyvault.models.secret_item_paged.SecretItemPaged object at 0x7fc494c78b38>
我不确定如何处理这个对象。文档没有给我任何提示,除非我错过了一些东西。