Azure Data Table Server failed to authenticate the request. Using DefaultAzureCredentials

Satria Priambada 0 Reputation points
2024-05-09T18:59:37.7566667+00:00

Hi, I'm trying to follow the tutorial for python application using DefaultAzureCredentials, but it said that my Authentication failed

from azure.data.tables import TableServiceClient
from azure.identity import DefaultAzureCredential

with TableServiceClient(
    endpoint="https://manufactureprovision.table.core.windows.net",
    credential=DefaultAzureCredential(),
) as table_service_client:
    properties = table_service_client.get_service_properties()
    print(f"{properties}")

Traceback (most recent call last):

File "C:\Users\Satria(Tio)Priambada\Downloads\ms-identity-python-desktop\1-Call-MsGraph-WithUsernamePassword\venv\lib\site-packages\azure\data\tables\_table_service_client.py", line 121, in get_service_properties

service_props = self._client.service.get_properties(timeout=timeout, **kwargs)

File "C:\Users\Satria(Tio)Priambada\Downloads\ms-identity-python-desktop\1-Call-MsGraph-WithUsernamePassword\venv\lib\site-packages\azure\core\tracing\decorator.py", line 78, in wrapper_use_tracer

return func(*args, **kwargs)

File "C:\Users\Satria(Tio)Priambada\Downloads\ms-identity-python-desktop\1-Call-MsGraph-WithUsernamePassword\venv\lib\site-packages\azure\data\tables\_generated\operations\_operations.py", line 2060, in get_properties

raise HttpResponseError(response=response, model=error)

azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.'

Content: <?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>AuthenticationFailed</m:code><m:message xml:lang="en-US">Server failed to authenticate the request.

Make sure the value of Authorization header is formed correctly including the signature.

RequestId:a7034abb-a002-000e-2b40-a23706000000

Time:2024-05-09T18:44:49.8505805Z</m:message></m:error>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "C:\Users\Satria(Tio)Priambada\Downloads\ms-identity-python-desktop\1-Call-MsGraph-WithUsernamePassword\a.py", line 8, in <module>

properties = table_service_client.get_service_properties()

File "C:\Users\Satria(Tio)Priambada\Downloads\ms-identity-python-desktop\1-Call-MsGraph-WithUsernamePassword\venv\lib\site-packages\azure\core\tracing\decorator.py", line 78, in wrapper_use_tracer

return func(*args, **kwargs)

File "C:\Users\Satria(Tio)Priambada\Downloads\ms-identity-python-desktop\1-Call-MsGraph-WithUsernamePassword\venv\lib\site-packages\azure\data\tables\_table_service_client.py", line 124, in get_service_properties

_process_table_error(error)

File "C:\Users\Satria(Tio)Priambada\Downloads\ms-identity-python-desktop\1-Call-MsGraph-WithUsernamePassword\venv\lib\site-packages\azure\data\tables\_error.py", line 210, in _process_table_error

raise decoded_error from storage_error

azure.core.exceptions.ClientAuthenticationError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.

RequestId:a7034abb-a002-000e-2b40-a23706000000

Time:2024-05-09T18:44:49.8505805Z

ErrorCode:AuthenticationFailed

{http://schemas.microsoft.com/ado/2007/08/dataservices/metadata}error:None

A possible cause of this error could be that the account URL used tocreate the Client includes an invalid path, for example the table name. Please check your account URL.

Content: <?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>AuthenticationFailed</m:code><m:message xml:lang="en-US">Server failed to authenticate the request.

Make sure the value of Authorization header is formed correctly including the signature.

RequestId:a7034abb-a002-000e-2b40-a23706000000

Time:2024-05-09T18:44:49.8505805Z</m:message></m:error>

I can see my resource from portal.azure.com without problemimage

I found the example instructions and code from https://pypi.org/project/azure-data-tables/

If someone can help me that'll be great!

Thanks and have a great day!

Azure Table Storage
Azure Table Storage
An Azure service that stores structured NoSQL data in the cloud.
170 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Satria Priambada 0 Reputation points
    2024-05-10T19:09:08.36+00:00

    I'm not using Visual Studio. I'm using MSAL https://pypi.org/project/msal/ to get auth token.

    I just want to use the auth token to access table like this post https://stackoverflow.com/questions/59406391/access-azure-blob-storage-of-a-user-using-oauth2-token-obtained

    I don't have firewall

    I do have Contributor role

    I don't have proxy


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.