0

I am tasked with trying to retrieve files from Azure through the use of a SAS token, but the documentation doesn't seem to lead me to a solution. When I attempt to generate the token programmatically with Java, I get the error "signature fields not well formed."

Here are the two pieces of documentation I am referencing:

  1. https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas

  2. https://learn.microsoft.com/en-us/rest/api/eventhub/generate-sas-token

Here is the code snippet I am using: image

I am using the proper key, keyName, and URI. I've used the search function and haven't found a solution yet. What is it that I'm missing?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

0

The problem is related with your 'stringToSign' variable.

The following should work:

String stringToSign = accountName + "\n" +
            "r\n" +
            "f\n" +
            "o\n" +
            start + "\n" +
            expiry + "\n" +
            "\n" +
            "https\n" +
            azureApiVersion+"\n";

PS: enter the desired start / expiry date for this token and use the latest api version.

Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90