Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Come on, Jump!

Maurice MJ de Jong MauRiEEZZZ

💭
Come on, Jump!
View GitHub Profile
View 48option2step5.py
secret_client = SecretClient(vault_uri, credential)
supersecret = secret_client.get_secret(secret_name)
print("The secret value is: "+ supersecret.value)
View 48option2step4.py
credential = DeviceCodeCredential(client_id, authority=authority_host_uri, tenant=tenant_id)
View 48option2step3.py
secret_name = 'ExamplePassword'
vault_uri = '<replace this text and brackets>'
tenant_id='<replace this text and brackets>'
authority_host_uri = 'login.microsoftonline.com'
keyvault_resource_uri = 'https://vault.azure.net'
client_id = '04b07795-8ddb-461a-bbee-02f9e1bf7b46'
View 48option2step2.py
from azure.identity import DeviceCodeCredential
from azure.keyvault.secrets import SecretClient
View 48option2step1.py
!pip install azure-identity --no-cache-dir --upgrade
!pip install azure-keyvault-secrets --no-cache-dir --upgrade
View 48option1step5.py
keyvault_client = KeyVaultClient(kv_credential)
supersecret = keyvault_client.get_secret(vault_uri, secret_name, '')
print("The secret value is: "+ supersecret.value)
View 48option1step4.py
context = adal.AuthenticationContext(authority_host_uri, api_version=None)
code = context.acquire_user_code(keyvault_resource_uri, client_id)
print(code['message'])
kv_token = context.acquire_token_with_device_code(keyvault_resource_uri, code, client_id)
kv_credential = AADTokenCredentials(kv_token, client_id)
View 48option1step3.py
secret_name = 'ExamplePassword'
vault_uri = '<replace this text and brackets>'
tenant_id='<replace this text and brackets>'
cloud=AZURE_PUBLIC_CLOUD
authority_host_uri = cloud.endpoints.active_directory + \
'/' + tenant_id
keyvault_resource_uri = 'https://vault.azure.net'
client_id = '04b07795-8ddb-461a-bbee-02f9e1bf7b46'
View 48option1step2.py
import adal, uuid, time
from msrestazure.azure_active_directory import AADTokenCredentials
from azure.keyvault import KeyVaultClient
from msrestazure.azure_cloud import AZURE_PUBLIC_CLOUD
View 48option1step1.py
!pip install msrestazure --no-cache-dir --upgrade
!pip install azure-keyvault --no-cache-dir --upgrade