Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure blob GET request authorization header "x-ms-date" field issue

I am trying to fetch a html page which is placed in Azure blob storage using postman. The default blob storage access has been set to private, so i have to send "Shared Key", "x-ms-version" and "x-ms-date" in the header section to Authorize.

Here is the screen shot of request in Postman.

enter image description here

When i click on send button i am getting an error stating "The date header in the request is incorrect".

enter image description here

Any ideas to solve the issue?

Update-Corrected Date Format

I corrected the "x-ms-date" format, now it throwing an error stating Authentication Info is not in correct format

enter image description here

Here is the Authorization section of postman

enter image description here

Thanks for the help.

like image 929
Subbi reddy dwarampudi Avatar asked Dec 19 '18 16:12

Subbi reddy dwarampudi


People also ask

What is X MS date?

Three of the headers are required: an Authorization header, x-ms-date (contains the UTC time for the request), and x-ms-version (specifies the version of the REST API to use).

How do I get blob metadata?

To retrieve metadata, call the GetProperties or GetPropertiesAsync method on your blob or container to populate the Metadata collection, then read the values, as shown in the example below. The GetProperties methods retrieve blob properties and metadata in a single call.

What is Blob_storage?

Azure Blob storage is a feature of Microsoft Azure. It allows users to store large amounts of unstructured data on Microsoft's data storage platform. In this case, Blob stands for Binary Large Object, which includes objects such as images and multimedia files.

Which authentication method should you use for blob storage?

Suggested Answer: You can provide authorization credentials by using Azure Active Directory (AD), or by using a Shared Access Signature (SAS) token. Box 1: Both Azure Active Directory (AD) and Shared Access Signature (SAS) token are supported for Blob storage.


2 Answers

Please review the documentation.

You need to specify two headers for correct request: Authorization and x-ms-date headers.

The correct format for x-ms-date header is Fri, 26 Jun 2015 23:39:12 GMT.

It seems your Authorization header is invalid. Try to regenerate your SAS key and test your request again.

As I understand correctly then you have only 15 minutes for requests.

From documentation:

The storage services ensure that a request is no older than 15 minutes by the time it reaches the service. This guards against certain security attacks, including replay attacks. When this check fails, the server returns response code 403 (Forbidden).

like image 155
Alexander I. Avatar answered Oct 22 '22 02:10

Alexander I.


The format is Fri, 26 Jun 2015 23:39:12 GMT. In Python, this can be obtained via

import datetime
date = datetime.datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')

assuming locale.en_US.

like image 3
Jorge Leitao Avatar answered Oct 22 '22 00:10

Jorge Leitao