I'm trying to get an access token by authenticating my app with AAD via a certificate. The certificate is installed on my local machine (windows 10). This authentication is needed to access an external API.
I'm following the steps posted on Azure Docs
Sample code:
def authenticate_client_cert():
"""
Authenticate using service principal w/ cert.
"""
authority_host_uri = 'https://login.microsoftonline.com'
tenant = '<TENANT>'
authority_uri = authority_host_uri + '/' + tenant
resource_uri = 'https://management.core.windows.net/'
client_id = '<CLIENT_ID>'
client_cert = '<CLIENT_CERT>' ### MISSING THIS
client_cert_thumbprint = '<CLIENT_CERT_THUMBPRINT>'
context = adal.AuthenticationContext(authority_uri, api_version=None)
mgmt_token = context.acquire_token_with_client_certificate(resource_uri, client_id, client_cert, client_cert_thumbprint)
credentials = AADTokenCredentials(mgmt_token, client_id)
return credentials
I have '<CLIENT_ID>', '<TENANT>' and '<CLIENT_CERT_THUMBPRINT>'
but I'm missing '<CLIENT_CERT>'
From my understanding, '<CLIENT_CERT>' is the private key but I cannot export the private key because it's not allowed.
So I'm not sure how I can get authenticated from AAD with this certificate.