0

I was toying with Azure Storage Blob PHP Client library the other day and I got a bit confused around how to use it in the BlobRestProxy::createBlobServiceWithTokenCredential method:

$connectionString = "DefaultEndpointsProtocol=https;BlobEndpoint=https://...";
$access_token = get_token_access($application_id, $application_secret, 'https://...');
$blobClient = BlobRestProxy::createBlobServiceWithTokenCredential($accessToken,$connectionString);
$blobClient->createBlockBlob($containerName, $fileName, $content);

I am getting the following error:

Authentication information is not given in the correct format. Check the value of Authorization header.

I can confirm the token is valid as I can use it to list the blobs in the container using the rest api.

  • Does this help https://poyu677.medium.com/%E9%80%8F%E9%81%8E-service-principle-%E6%93%8D%E4%BD%9C-azure-storage-account-%E4%BD%BF%E7%94%A8-python-php-9baa5d09d470? Please check the **Using PHP** section. – Rukmini Oct 31 '22 at 07:36

1 Answers1

0

Authentication information is not given in the correct format. Check the value of Authorization header.

The above error shows that you have passed either incorrect header or you have missed something in the Authorization header.

  1. Make sure your connection string is in correct format:

Connection string:

DefaultEndpointsProtocol=https or http ;AccountName=< Account name>;AccountKey=< Account key >;EndpointSuffix=core.windows.net

you can get the connection string through portal under your storage account:

Home -> storage account ->security + networking (Access key )

enter image description here

  1. Make sure your PC is running in correct state of (Time and date), Also check whether your PC enable with VPN or Not.
  2. If the file has metadata, it shouldn't have any special characters () or extra spaces () at the beginning or end of the value.

Reference: "Authentication not in correct format" when setting Azure Blob Service Properties (REST API) - Stack Overflow

Venkatesan
  • 3,748
  • 1
  • 3
  • 15