Open msl0 opened 1 year ago
https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/identity/azure-identity/migration_guide.md looks like Microsoft need to update this module to support the azure-identity credentials; until then it won't work
Edit: https://github.com/Azure/azure-sdk-for-python/issues/15330#issuecomment-728163487 this may be a workaround
I have prepared a working workaround using the msrest.authentication library. Unfortunately msrest is also deprecated, but it looks like Microsoft still uses it in their projects (az cli).
from azure.identity import DefaultAzureCredential
from msrest.authentication import BasicTokenAuthentication
from azure.devops.connection import Connection
credential = DefaultAzureCredential()
token = credential.get_token('499b84ac-1321-427f-aa17-267ca6975798/.default')
credentials = BasicTokenAuthentication({'access_token': token.token})
organization_url = 'https://dev.azure.com/myorg'
connection = Connection(base_url=organization_url, creds=credentials)
core_client = connection.clients.get_core_client()
get_projects_response = core_client.get_projects()
if get_projects_response:
for project in get_projects_response:
print(project.name)
@msl0 workaround worked for me. thanks!
Bumping
Bump
Bumping this. Can we have proper support for Azure Identity (DefaultAzureCredential, etc) on ADO Python API Library?
Just like other SDKs, following should work without any workaround.
credential = DefaultAzureCredential()
organization_url = 'https://dev.azure.com/myorg'
connection = Connection(base_url=organization_url, creds=credentials)
CC: @apudovkin-ms, @nechvatalp, @jasinshaban, @tonybaloney
I'm trying to create a python script to interact with Azure DevOps and I have problem with authentication. I don't want to use PAT. This works but I noticed it is recommended to use
azure.identity
instead ofazure.common.credentials.get_azure_cli_credentials()
.When I try to use
DefaultAzureCredential
fromazure.identity
, I get following error:azure.identity = 1.12.0 azure.devops = 7.1.0b3 azure.common = 1.1.11