0

I'm having trouble trying to send a POST message to an Azure SB Queue using PostMan.

The error I get is 401 40103: Invalid authorization token signature My issue is generating the SAS as I'm trying to follow various articles and examples but I must be missing/overlooking/not understanding something.

If I describe what I've done, hopefully it'll become obvious where I'm making a mistake.

My Queue URL is https://GTRAzure.servicebus.windows.net/subscriptionpreference My Policy is Submit I've chosen an expiry date for December: 1512086400

My string-to-sign is https://gtrazure.servicebus.windows.net/subscriptionpreference\n1512086400 which is then encoded as https%3A%2F%2Fgtrazure.servicebus.windows.net%2Fsubscriptionpreference%5Cn1512086400

I then sign this using the Primary Key I get from the Submit policy. I'm using this to test: https://www.freeformatter.com/hmac-generator.html

This generates a code like 425d5ff8beb8da58e6f97e45462037e25ea56bcb63470f9b28761fa012f61090 using SHA-256 Which I then base-64 encode to get NDI1ZDVmZjhiZWI4ZGE1OGU2Zjk3ZTQ1NDYyMDM3ZTI1ZWE1NmJjYjYzNDcwZjliMjg3NjFmYTAxMmY2MTA5MA==

I then put it all together to get this which I place in the text of the Authorization header SharedAccessSignature sig=NDI1ZDVmZjhiZWI4ZGE1OGU2Zjk3ZTQ1NDYyMDM3ZTI1ZWE1NmJjYjYzNDcwZjliMjg3NjFmYTAxMmY2MTA5MA==&se=1512086400&skn=Submit=&sr=https%3A%2F%2Fgtrazure.servicebus.windows.net%2Fsubscriptionpreference%5Cn1512086400

Chris Crawshaw
  • 287
  • 5
  • 21

1 Answers1

3

I think the string to sign which you are providing is incorrect because \n is not getting treated as new line which generates encoded value as :

https%3A%2F%2Fgtrazure.servicebus.windows.net%2Fsubscriptionpreference%5Cn1512086400

which gives Authorization failure.

But if it is treated as new line, it will give value like this:

https%3A%2F%2Fgtrazure.servicebus.windows.net%2Fsubscriptionpreference%0A1512086400

which will not give error.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
Jagrati Modi
  • 2,038
  • 1
  • 13
  • 26