java - How to access Azure Storage Table using REST API (ARM) -


by looking following link it's not clear signature should contain or how form canonical string create signature can encrypted using hmac-sh256 alogrithm.

https://msdn.microsoft.com/en-us/library/azure/dd179428.aspx

i using following url

get https://mystorageaccount.table.core.windows.net/tables

headers:

authorization   sharedkeylite mystorrageaccount:<<encrypted signature>> x-ms-date   thu 28 jul 2016 11:19:33 gmt 

getting following error:

server failed authenticate request. make sure value of authorization header formed correctly including signature.

@prit, please see code below generating shared key lite of table storage reference.

import java.security.invalidkeyexception; import java.security.nosuchalgorithmexception; import java.text.simpledateformat; import java.util.calendar; import java.util.locale; import java.util.timezone;  import javax.crypto.mac; import javax.crypto.spec.secretkeyspec;  import org.apache.commons.codec.binary.base64;  string secret = "<storage-account-key>"; // date string sign calendar calendar = calendar.getinstance(); simpledateformat sdf = new simpledateformat("eee, d mmm yyyy hh:mm:ss 'gmt'", locale.us); sdf.settimezone(timezone.gettimezone("gmt")); string date = sdf.format(calendar.gettime()); // canonicalizedresource, such "/testaccount1/tables" string canonicalizedresource = "<canonicalized-resource>"; string stringtosign = date + "\n" + canonicalizedresource; system.out.println(stringtosign); // hmac-sha@%^ mac sha256hmac = mac.getinstance("hmacsha256"); secretkeyspec secretkey = new secretkeyspec(secret.getbytes(), "hmacsha256"); sha256hmac.init(secretkey); string hash = base64.encodebase64string(sha256hmac.dofinal(stringtosign.getbytes())); system.out.println(hash); 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -