locked
get_blob_properties is returning exception "azure.common.AzureHttpError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature." RRS feed

  • Question

  • In python get_blob_properties is returning exception "azure.common.AzureHttpError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly  including the signature."

    Below is my code snippet:

    block_blob_service = BlockBlobService(account_name=<MyBlobAccountName>, sas_token=<SAS_KEYOFMYBLOB>)

    blobSysProperties = block_blob_service.get_blob_properties(<MYContainerName>, "<MyBlobFileName>")

    Note: <SAS_KEYOFMYBLOB> is generated from C# application with the starttime as -48hrs and endtime = +72 hrs and I tried using the SAS Key in the browser and able to download my blob file. Below is the C# code snippet for sas generation:

           

     //Get a reference to a blob within the container.
               CloudBlockBlob blob = container.GetBlockBlobReference("ScrapXX.txt");


      //The shared access signature will be valid immediately.
               SharedAccessBlobPolicy sasConstraints = new SharedAccessBlobPolicy();
               sasConstraints.SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-2880);
               sasConstraints.SharedAccessExpiryTime = DateTime.UtcNow.AddHours(72);
               sasConstraints.Permissions = SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.Read | SharedAccessBlobPermissions.Delete | SharedAccessBlobPermissions.List;

      //Generate the shared access signature on the blob, setting the constraints directly on the signature.
               string sasBlobToken = blob.GetSharedAccessSignature(sasConstraints);

      //Return the URI string for the container, including the SAS token.
               return blob.Uri + sasBlobToken;

     

    Wednesday, August 24, 2016 12:06 PM

Answers

  • Hi all,

    I found the problem I made a minor issue when using the SAS_Token, it got generated with "?" in the beginning of the token, when i removed it and consumed the token it is working fine.

    Monday, August 29, 2016 7:13 AM

All replies

  • Hi Harish,

    Thank you for posting here! We are happy to assist you.

    It may be the timing issue. Refer to the below mentioned link and let us know the status.

    https://blogs.msdn.microsoft.com/kwill/2013/08/27/http-403-server-failed-to-authenticate-the-request-when-using-shared-access-signatures/

    Regards,
    Sumanth BM

    Wednesday, August 24, 2016 7:37 PM
  • Sumanth - Thanks for the reponse, but I see this is not a timing issue because, below is my code snippet, I gave negative value for the start and positive value for the expiry.

      sasConstraints.SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-2880);
               sasConstraints.SharedAccessExpiryTime = DateTime.UtcNow.AddHours(72);

    Thursday, August 25, 2016 5:26 AM
  • Hi all,

    I found the problem I made a minor issue when using the SAS_Token, it got generated with "?" in the beginning of the token, when i removed it and consumed the token it is working fine.

    Monday, August 29, 2016 7:13 AM
  • Hi Harish,

    Thanks' for  the update!

    Regards,
    Sumanth BM

    Tuesday, August 30, 2016 12:02 PM