GooglePro
GooglePro

Reputation: 33

Google Distance Matrix Rest template call with digital signature generation returning 403 forbidden

I am trying to access the google distance matrix from rest template. I have a valid API key and when I make a call from browser it seems to work fine. I used the google code present in this link to generate the google signature. When I take the digital signature and append it to the URL manually it seems to work fine.

The problem arises when I am passing that through rest template. The call seems to work but I am getting a 403 forbidden. I did a bit or research and it seems like my digital signature is invalid for the respective URL. Can anyone clarify how my URL is valid from browser and why it is invalid from a rest template call?

Upvotes: 1

Views: 234

Answers (1)

Coder
Coder

Reputation: 2239

If you pass a URL to the rest template it will mostly convert into an encoded URL which will bear the same the digital signature. But as this URL is different from the URL which you had generated digital signature, this signature will become invalid for the encoded URL.

Instead of making the rest template call which takes URL make use of URI. URI's won't be encoded by the rest template and you can validate your digital signature with the the respective URI.

Let me know if you need further clarification!!

Upvotes: 2

Related Questions