none
Windows Azure storage Rest Api error: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.

    Question

  • i have been trying to upload video/audio to my azure storage account. I'm using objective-c with REST API for all the operations, so far i've created an asset file in the storage and got the upload url successfully . Now i try to get all the containers in my storage, but getting Authentication error. Below is my code,

    -(void)ListAllContainers{

        NSString* signature = @"GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Wed, 08 Jul 2015 21:55:00 GMT\nx-ms-version:2014-02-14\n/StorageAccountName/\ncomp:list";

        NSString* Key = @"MyStorageAccountPrimaryKey";

        NSString *encodedSignature = [self generateSecretForAzureStorageAuthForSecret:Key andData:signature];

    // after hashin i got "AEPedDCPbbK5TSNCCthJUybPMP4yZJvGv7Ihh3SxOGQ="  as encodedSignature

        NSString *authorizationValue = [NSString stringWithFormat:@"SharedKey StorageAccountName:%@",encodedSignature];

        NSString *BaseURL = @"https://StorageAccountName.blob.core.windows.net"

        NSURL *aUrl = [NSURL URLWithString:@"BaseURL/?comp=list"];

        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:aUrl

                                                               cachePolicy:NSURLRequestReloadIgnoringLocalCacheData

                                                           timeoutInterval:160.0];

        [request setHTTPMethod:@"GET"];

        [request setValue:authorizationValue forHTTPHeaderField:@"Authorization"];

        [request setValue:@"Wed, 08 Jul 2015 21:55:00 GMT" forHTTPHeaderField:@"x-ms-date"];

        [request setValue:@"2014-02-14" forHTTPHeaderField:@"x-ms-version"];

        NSOperationQueue *queue = [[NSOperationQueue alloc] init];

        [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)

         {

             NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;

             NSString* responseStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

             NSLog(@"\n status code: %ld  res: %@ ", (long)[httpResponse statusCode],responseStr);

         }];

    }


     OUTPUT:

    status code: 403  res:

    <?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:c95b425d-0001-00ac-489a-b9096a000000

    Time:2015-07-08T16:22:47.3037605Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request 'AEPedDCPbbK5TSNCCthJUybPMP4yZJvGv7Ihh3SxOGQ=' is not the same as any computed signature. Server used following string to sign: 'GET

    x-ms-date:Wed, 08 Jul 2015 21:55:00 GMT

    x-ms-version:2014-02-14

    /mediasvcnxvcw0wnmq4xp/

    comp:list'.</AuthenticationErrorDetail></Error>

    How can i ensure that the encoded signature is correct ? Where the error could be ?

     

    • Moved by Asha99 Thursday, July 9, 2015 4:45 AM related to azure storage
    • Edited by goodnezeverywer Thursday, July 9, 2015 8:31 AM
    Wednesday, July 8, 2015 5:40 PM

Answers

  • Hi,

    I see this as a common error irrespective of REST API or uploading(audio / vedio ). Sharing it here so that it can be of any help.

    If this doesn't help, we might have to look into the Fiddler trace for further understanding on what is causing the authentication issue.

    Regards,

    Shirisha Paderu

    Thursday, July 9, 2015 1:11 PM
    Moderator