Skip to content

BlockBlobService fails to authenticate with SAS token #462

@thoyt

Description

@thoyt

Which service(blob, file, queue) does this issue concern?

Blob service

What problem was encountered?

When trying to list blobs with a BlockBlobService object initialized with an SAS token instead of an access key, I get an error saying "sr is mandatory. Cannot be empty". It works when initialized with an account_key instead of an sas_token. Here are the steps to repro:

from azure.storage.blob import BlockBlobService

bs = BlockBlobService(account_name=<account_name>, sas_token=<sas_token>)
bs.list_blobs(<container_name>)

Output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Volumes/Backups/azure-backup-venv/lib/python3.6/site-packages/azure/storage/blob/baseblobservice.py", line 1214, in list_blobs
    resp = self._list_blobs(*args, **kwargs)
  File "/Volumes/Backups/azure-backup-venv/lib/python3.6/site-packages/azure/storage/blob/baseblobservice.py", line 1285, in _list_blobs
    return self._perform_request(request, _convert_xml_to_blob_list, operation_context=_context)
  File "/Volumes/Backups/azure-backup-venv/lib/python3.6/site-packages/azure/storage/storageclient.py", line 280, in _perform_request
    raise ex
  File "/Volumes/Backups/azure-backup-venv/lib/python3.6/site-packages/azure/storage/storageclient.py", line 248, in _perform_request
    raise ex
  File "/Volumes/Backups/azure-backup-venv/lib/python3.6/site-packages/azure/storage/storageclient.py", line 235, in _perform_request
    _http_error_handler(HTTPError(response.status, response.message, response.headers, response.body))
  File "/Volumes/Backups/azure-backup-venv/lib/python3.6/site-packages/azure/storage/_error.py", line 114, in _http_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"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:da2104c4-f01e-0039-225d-ff3140000000
Time:2018-06-08T19:19:43.8006489Z</Message><AuthenticationErrorDetail>sr is mandatory. Cannot be empty</AuthenticationErrorDetail></Error>

I'm not sure exactly which azure python packages are relevant but here are the azure-storage packages:

azure-storage==0.36.0
azure-storage-blob==1.1.0
azure-storage-common==1.1.0
azure-storage-file==1.1.0
azure-storage-nspkg==3.0.0
azure-storage-queue==1.1.0

The base azure packages are azure-mgmt==2.0.0 and azure==3.0.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions