I’m following this example to test signing my URLs in Java:
Class Libraries & REST APIs for the developers to manipulate & process Files from Word, Excel, PowerPoint, Visio, PDF, CAD & several other categories in Web, Desktop or Mobile apps. Develop & deploy on Windows, Linux, MacOS &...
I’m using the URL, appSID, and key specified in the example and running the same function:
String url = “**http://api.saaspose.com/storage/folder/test_folder?appSID=c821f123-1a8b-4b97-925a-9d69a6b2fcd8**”;
String key = “**23e9d89a967a5f18142221fa8f7cbcd0**”;
byte[] keyBytes = key.getBytes();
SecretKeySpec signingKey = new SecretKeySpec(keyBytes, "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(signingKey);
byte[] hexBytes = new Hex().encode(rawHmac);
String result = new String(hexBytes, "UTF-8");
At this point, the example says the result should be Z98TBrlwdtx3pTa6fWVD/Q0c2dE= but I am getting 67df1306b97076dc77a536ba7d6543fd0d1cd9d1
Obviously I need this to be correct before I can start using Saaspose. What is wrong?
Hi Andy,
Thanks for your inquiry. I would like to update you that you don’t need to prepare URL signing method. You can call an existing “sign” method available at the following link here . You just need to pass single URL parameter e.g. http://api.saaspose.com/v1.0/storage/folder/myfolder
. You can download the Java SDK from here and please try the following source code below:
Product.*setBaseProductUri*(“http://api.saaspose.com/v1.0”);
SaasposeApp.*setAppSID*(“********************"********************);
SaasposeApp.*setAppKey*("”);
String signedURI = Utils.Sign(“http://api.saaspose.com/v1.0/storage/folder/test_folder”);
System.out.println(Utils.StreamToString(Utils.ProcessCommand(signedURI, “GET”)));
Note: Please sign up for the Saaspose trial account and try to use your own AppSID and AppKey.
Please let me know in case of further assistance and comments.