azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Exception when trying to connect with DataLakeServiceClient using invalid ClientSecretCredential credentials

Open nee2shaji opened this issue 2 years ago • 3 comments

  • Package Name: azure-storage-file-datalake
  • Package Version: 12.14.0
  • Operating System: macOS Ventura 13.6.1
  • Python Version: 3.7.12

Describe the bug Try to connect with DataLakeServiceClient using invalid ClientSecretCredential credentials. It throws an exception in here - AttributeError: 'str' object has no attribute 'get'

To Reproduce Try this sample code below.

from azure.storage.filedatalake.aio import DataLakeServiceClient
from azure.identity.aio import ClientSecretCredential
import asyncio


client_id = <client_id>
tenant_id = <tenant_id>
client_secret = <invalid_client_secret>   
account_name = <account_name>

creds = ClientSecretCredential(tenant_id, client_id, client_secret)


async def func():
    async with DataLakeServiceClient("https://{}.dfs.core.windows.net".format(account_name), credential=creds) as dls_client:
        await dls_client.get_file_system_client('dummy-test').exists()

asyncio.run(func())

Expected behavior It should've thrown an exception ClientAuthenticationError

Additional context If we import from from azure.identity import ClientSecretCredential, it throws proper exception ClientAuthenticationError. The attribute error exception occurs when we import from from azure.identity.aio import ClientSecretCredential

nee2shaji avatar Dec 12 '23 18:12 nee2shaji

Thanks for the feedback, we’ll investigate asap.

xiangyan99 avatar Dec 12 '23 19:12 xiangyan99

Hi @nee2shaji, thanks for bringing the issue to our attention. I was able to reproduce this and tracked down the issue to be caused by a small difference in how azure-identity` handles authentication errors between their sync and async classes. I just put up a PR to fix this issue. This change will come in our next release planned for early next year. Thanks again.

jalauzon-msft avatar Dec 15 '23 01:12 jalauzon-msft

Thank you!

nee2shaji avatar Dec 15 '23 12:12 nee2shaji