Skip to main content
Known Participant
July 3, 2019
Answered

How to hide an API key

  • July 3, 2019
  • 1 reply
  • 2101 views

Using Dreamweaver CC 2019 Google Maps now requires the API key be embedded in the js script source, for their free maps so I have had to add API keys to a couple of my sites. They warn that these API keys should be hidden to avoid misuse. How to I achieve this?

Here is the call out: <script src="//maps.googleapis.com/maps/api/js?key=MY_API_KEY&v=3.exp&sensor=false"></script>

I need to keep the info relating to my API key hidden. Eventually, I want to switch the maps out with another free map that doesn't need to be monitored so closely to avoid fees and abuse. In the meantime, I am hoping for a quick fix to keep the key hidden.

This topic has been closed for replies.
Correct answer Nancy OShea

You cannot hide code in static HTML files.   But you can hide code within variables inside server-side scripts like PHP.   See Google's Best Practices

Google Maps Platform  |  Google Developers

1 reply

Nancy OShea
Community Expert
Community Expert
July 3, 2019

You need to set-up API restrictions.  See the Google documentation.

Using API Keys  |  Authentication  |  Google Cloud

Nancy O'Shea— Product User & Community Expert
Known Participant
July 5, 2019

Nancy, I decided to close my Google billing account instead and will remove the maps from my sites. After several days debugging this issue, I'm finding the solution much too risky.