I've created a Google API key and using it to show maps in my Android application. For security reasons it is recommended that we should apply restrictions to the API so attackers cannot use it easily.
So I applied restrictions like below image:
And my app works perfectly with current restrictions. Now when I'm trying to access maps with this request (via browser):
https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&key=AIxxxxxxxxxxxxxxxxxxxxxxxx&signature=6d2cd94cb942dcc8da184cb28cf0e1a0f53e5837
Where key is my real API key but the signature is a totally random SHA1 it gives me this error:
The Google Maps Platform server rejected your request. Unable to authenticate the request. Provided 'signature' is not valid for the provided API key, or the provided 'key' is not valid.
Which makes sense, since it's not my application SHA1 and also Im accessing GoogleMap API with web browser not with an Android app.
However if I remove the signature query parameter from request It works. Now if someone decompile my app and grab the API key from app's AndroidManifest file, he can easily use this key to make a lot of API requests and abuse my key. It appears that this restrictions doesn't work or am I misunderstood something? How can I restrict this key to be only usable with my Android app?