Highlighted

How to hide an API key

Participant ,
Jul 03, 2019

Copy link to clipboard

Copied

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.

Adobe Community Professional
Correct answer by Nancy OShea | Adobe Community Professional

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

Views

661

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to hide an API key

Participant ,
Jul 03, 2019

Copy link to clipboard

Copied

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.

Adobe Community Professional
Correct answer by Nancy OShea | Adobe Community Professional

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

Views

662

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 03, 2019 0
Adobe Community Professional ,
Jul 03, 2019

Copy link to clipboard

Copied

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

Using API Keys  |  Authentication  |  Google Cloud

Nancy O'Shea, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 03, 2019 1
Participant ,
Jul 05, 2019

Copy link to clipboard

Copied

Thank you. Yes, Google Support did suggest setting restrictions to 100,000 to avoid abuse that would incur costs. Although I have not found where that setting is in their restrictions section. But - They also said I needed to "hide" the key that is showing up in my code. We didn't use to have to add the key for free maps. But Google support said that now, we do. But the tech warned that I should definitely "hide" it so it doesn't get abused. I'm thinking of removing the map since having it seems to open us up to credit card abuse via this key that should not incur any costs. Is there a way in DreamWeaver CC 2019 to hide code, so that when someone uses a developer tool in a browser to view the code, they can't see it? This is actually what my question boils down to. Thanks for trying to help!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 05, 2019 0
Adobe Community Professional ,
Jul 05, 2019

Copy link to clipboard

Copied

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

Nancy O'Shea, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 05, 2019 1
Participant ,
Jul 05, 2019

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 05, 2019 0