简体   繁体   中英

Google Maps Java API - Linking API key

I'm currently learning Google maps Java API

This might be a stupid question, but I noticed that the documentation recommends linking to the API key like so:

<script type="text/javascript"
    src="https://maps.googleapis.com/maps/api/js?key=API_KEY">
</script>

I realise you can restrict your API usage by domain, but is there a safer way of linking this? Or should I just not argue with google?

Thanks heaps,

Kieran

Got to the same question a few weeks ago, and you should not argue with google. You can restrict the domains that can access your api key in your google api console, so if you have a repository on github, you can restrict it to your username, like username.github.io/*, but that will also block you it in your localhost(unless you get a static IP, then you can whitelist it locally), so I recommend just keeping it to yourself, and restricting if you want to share your code with the world.

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