Azure / azure-storage-python

Microsoft Azure Storage Library for Python
https://azure-storage.readthedocs.io
MIT License
338 stars 240 forks source link

Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. #588

Closed RotemAmergi closed 5 years ago

RotemAmergi commented 5 years ago

Hi ,

I am using the azure.storage.queue for query the amount of files in storage accounts.

I got thus error :

''' File "GetAzureQueueSize.py", line 59, in main() File "GetAzureQueueSize.py", line 55, in main check_all(azure_storage_accounts_mapping) File "GetAzureQueueSize.py", line 32, in check_all dict = get_queu_of_storage_account(account_name, account_key) File "GetAzureQueueSize.py", line 23, in get_queu_of_storage_account queues = queue_service.list_queues("") File "/usr/local/lib/python2.7/dist-packages/azure/storage/queue/queueservice.py", line 223, in list_queues response = self._perform_request(request) File "/usr/local/lib/python2.7/dist-packages/azure/storage/storageclient.py", line 178, in _perform_request _storage_error_handler(ex) File "/usr/local/lib/python2.7/dist-packages/azure/storage/_serialization.py", line 25, in _storage_error_handler return _general_error_handler(http_error) File "/usr/local/lib/python2.7/dist-packages/azure/storage/_common_error.py", line 82, in _general_error_handler raise AzureHttpError(message, http_error.status) azure.common.AzureHttpError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. <?xml version="1.0" encoding="utf-8"?>AuthenticationFailedServer failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:d43f63a3-0003-0075-64bc-00d9f3000000 Time:2019-05-02T07:57:44.0663918ZThe MAC signature found in the HTTP request 'NSIVg/XWNzIYfaMfr+o4GZjLSr7+tN9Ca58j+75yk7Q=' is not the same as any computed signature. Server used following string to sign: 'GET

application/octet-stream Charset=UTF-8

x-ms-date:Thu, 02 May 2019 07:57:44 GMT x-ms-version:2014-02-14 /bitdamprod1/ comp:list prefix:'. '''

RotemAmergi commented 5 years ago

What fix it it's to use :

azure-storage==0.34.0 azure-storage-common==1.3.0 azure-storage-queue==1.4.0

zezha-msft commented 5 years ago

Hi @RotemEmergi, please avoid using the deprecated package azure-storage. Please uninstall all packages and reinstall azure-storage-queue.

KacperKubara commented 1 year ago

I have the same issue, while using azure-storage-blob.

Within the function, I have the code that fails here:

 raw_blob = BlobClient.from_blob_url(document.uri, credential=STORAGE_KEY)

Resulting in:

[2023-02-27T10:21:44.501Z] Executed 'Functions.readBlob' (Failed, Id=bc25ac21-4c54-443f-b035-8cc421d64528, Duration=849ms)
[2023-02-27T10:21:44.501Z] System.Private.CoreLib: Exception while executing function: Functions.readBlob. System.Private.CoreLib: Result: Failure
[2023-02-27T10:21:44.501Z] Exception: ClientAuthenticationError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
[2023-02-27T10:21:44.501Z] RequestId:ec2671ee-901e-0036-4695-4a930a000000
[2023-02-27T10:21:44.501Z] Time:2023-02-27T10:21:44.4920183Z
[2023-02-27T10:21:44.501Z] ErrorCode:AuthenticationFailed
[2023-02-27T10:21:44.501Z] authenticationerrordetail:The MAC signature found in the HTTP request 'Okje3xm4+LWHK4pxhj8BIqfxXuHpXbNYYE3wR4pwbgE=' is not the same as any computed signature. Server used following string to sign: 'GET
[2023-02-27T10:21:44.501Z] 
[2023-02-27T10:21:44.501Z] 
[2023-02-27T10:21:44.501Z] 
[2023-02-27T10:21:44.501Z] 
[2023-02-27T10:21:44.501Z] 
[2023-02-27T10:21:44.501Z] 
[2023-02-27T10:21:44.501Z] 
[2023-02-27T10:21:44.501Z] 
[2023-02-27T10:21:44.501Z] 
[2023-02-27T10:21:44.501Z] 
[2023-02-27T10:21:44.501Z] 
[2023-02-27T10:21:44.501Z] x-ms-client-request-id:88c099ee-b688-11ed-9ecf-8e1aa50d398b
[2023-02-27T10:21:44.501Z] x-ms-date:Mon, 27 Feb 2023 10:21:44 GMT
[2023-02-27T10:21:44.501Z] x-ms-range:bytes=0-33554431
[2023-02-27T10:21:44.501Z] x-ms-version:2021-12-02
[2023-02-27T10:21:44.501Z] /stpdfextractiontool4pc6y/data-batch/verkennend%20onderzoek%20132309.pdf'.
[2023-02-27T10:21:44.501Z] Content: <?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
[2023-02-27T10:21:44.502Z] RequestId:ec2671ee-901e-0036-4695-4a930a000000
[2023-02-27T10:21:44.502Z] Time:2023-02-27T10:21:44.4920183Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request 'Okje3xm4+LWHK4pxhj8BIqfxXuHpXbNYYE3wR4pwbgE=' is not the same as any computed signature. Server used following string to sign: 'GET
[2023-02-27T10:21:44.502Z] 
[2023-02-27T10:21:44.502Z] 
[2023-02-27T10:21:44.502Z] 
[2023-02-27T10:21:44.502Z] 
[2023-02-27T10:21:44.502Z] 
[2023-02-27T10:21:44.502Z] 
[2023-02-27T10:21:44.502Z] 
[2023-02-27T10:21:44.502Z] 
[2023-02-27T10:21:44.502Z] 
[2023-02-27T10:21:44.502Z] 
[2023-02-27T10:21:44.502Z] 
[2023-02-27T10:21:44.502Z] x-ms-client-request-id:88c099ee-b688-11ed-9ecf-8e1aa50d398b
[2023-02-27T10:21:44.502Z] x-ms-date:Mon, 27 Feb 2023 10:21:44 GMT
[2023-02-27T10:21:44.502Z] x-ms-range:bytes=0-33554431
[2023-02-27T10:21:44.502Z] x-ms-version:2021-12-02
[2023-02-27T10:21:44.502Z] /stpdfextractiontool4pc6y/data-batch/verkennend%20onderzoek%20132309.pdf'.</AuthenticationErrorDetail></Error>
[2023-02-27T10:21:44.502Z] Stack:   File "/usr/local/Cellar/azure-functions-core-tools@4/4.0.4915/workers/python/3.9/OSX/X64/azure_functions_worker/dispatcher.py", line 458, in _handle__invocation_request
[2023-02-27T10:21:44.502Z]     call_result = await self._loop.run_in_executor(
[2023-02-27T10:21:44.502Z]   File "/Users/kacper/miniconda3/envs/rosetta/lib/python3.9/concurrent/futures/thread.py", line 58, in run
[2023-02-27T10:21:44.502Z]     result = self.fn(*self.args, **self.kwargs)
[2023-02-27T10:21:44.502Z]   File "/usr/local/Cellar/azure-functions-core-tools@4/4.0.4915/workers/python/3.9/OSX/X64/azure_functions_worker/dispatcher.py", line 701, in _run_sync_func
[2023-02-27T10:21:44.502Z]     return ExtensionManager.get_sync_invocation_wrapper(context,
[2023-02-27T10:21:44.502Z]   File "/usr/local/Cellar/azure-functions-core-tools@4/4.0.4915/workers/python/3.9/OSX/X64/azure_functions_worker/extension.py", line 215, in _raw_invocation_wrapper
[2023-02-27T10:21:44.502Z]     result = function(**args)
[2023-02-27T10:21:44.502Z]   File "/Users/kacper/Desktop/repos/minimal-azure-functions/readBlob/__init__.py", line 45, in main
[2023-02-27T10:21:44.502Z]     raw_blob.download_blob().readinto(data)
[2023-02-27T10:21:44.502Z]   File "/Users/kacper/Desktop/repos/minimal-azure-functions/.venv/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer
[2023-02-27T10:21:44.502Z]     return func(*args, **kwargs)
[2023-02-27T10:21:44.502Z]   File "/Users/kacper/Desktop/repos/minimal-azure-functions/.venv/lib/python3.9/site-packages/azure/storage/blob/_blob_client.py", line 914, in download_blob
[2023-02-27T10:21:44.502Z]     return StorageStreamDownloader(**options)
[2023-02-27T10:21:44.502Z]   File "/Users/kacper/Desktop/repos/minimal-azure-functions/.venv/lib/python3.9/site-packages/azure/storage/blob/_download.py", line 366, in __init__
[2023-02-27T10:21:44.502Z]     self._response = self._initial_request()
[2023-02-27T10:21:44.502Z]   File "/Users/kacper/Desktop/repos/minimal-azure-functions/.venv/lib/python3.9/site-packages/azure/storage/blob/_download.py", line 466, in _initial_request
[2023-02-27T10:21:44.502Z]     process_storage_error(error)
[2023-02-27T10:21:44.502Z]   File "/Users/kacper/Desktop/repos/minimal-azure-functions/.venv/lib/python3.9/site-packages/azure/storage/blob/_shared/response_handlers.py", line 189, in process_storage_error
[2023-02-27T10:21:44.502Z]     exec("raise error from None")   # pylint: disable=exec-used # nosec
[2023-02-27T10:21:44.502Z]   File "<string>", line 1, in <module>

My STORAGE_KEY is the connection string that I can find under storage account keys. Does anyone have that issue as well? I am using MacOS ventura