0
votes

Getting -"Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature." when authenticating for an azure storage client. All works well from the xcode simulator. Both uploading , downloading and creating new container. But from my iOS devices, an iPhone 5s and iPad air i cant authenticate.

The code (swift)

credential = AuthenticationCredential(azureServiceAccount:"myStorageAccount",accessKey:"myKeyIsHere") client = CloudStorageClient(credential:credential)

Ive seen questions regarding some similar issues from windows OS where the answers seems to be pointing in the direction of the machine clock not being in sync with the server.

But in my case I cant really see any clock/time issues.

Any clues?

1
A few things you may want to check: 1) Please ensure that account name/key is correct. 2) Please check the time on the devices to make sure they are not off by more than 15-20 minutes. These are the two main causes of authorization failure.Gaurav Mantri
Account name and key are definitely right. My device is running on central european time and the server is running on some american timeline. Guess this is handled and is not the problem. Something i quite cant grasp is how azure storage authentication is made so brittle that it fails if someones device has a time offset to the original time. Why isn't the authentication done in the same manner as eg. azure mobile serviceKnutdag
It is not brittle, the time factor is for security purpose. About 15-20 minutes of clock skew is allowed but if it is more than that, you will get an error. This is because to prevent someone taking the authorization header and keep on repeating the requests for a long duration.Gaurav Mantri
Are you using some particular library for accessing Azure Storage? I can't tell by looking at your code above. In particular, are you writing your own code for authentication? If so, that may be a place to look, although it's very weird that it works on the simulator but not a device.Adam Sorrin - MSFT
Also, is it possible that the HTTP requests from the device are somehow getting modified in-transit, in such a way that doesn't happen from the iPhone simulator? If something in the middle is modifying the HTTP requests in some way, that can cause auth to fail because it can change the string-to-signAdam Sorrin - MSFT

1 Answers

0
votes

Hmmm are you using the Azure Storage iOS Client Library?

If so, your swift code should be

let storageAccount = AZSCloudStorageAccount(fromConnectionString: yourConnectionString)

This getting started should also help.