简体   繁体   中英

Hide Google Maps Key

I have some code that shows an image of a location like:

    <img alt="Gym" src="https://maps.googleapis.com/maps/api/streetview?location=43.035419,-89.380748&size=456x456&**key=<api key>**"/>

The problem is that the is now exposed to the public. Google Maps has a component that essentially hides the key (at least the way I understand it). Is there something similar for this "streetview" API?

The developers.google guide lines suggest you to restrict the keys so they can only be used inside you website (preferably it should be allowed just for a single page not the entire website), use a different key for each website, and monitor for any anomalies in key usage.

But if are really want to obfuscate the key you can write it inside your code using a simple Cesar Cipher and translating it before sending it to Google, at the end this is a terrible security feature and will only protect you against basic bots.

https://developers.google.com/maps/api-key-best-practices

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM