• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to hide an API key

Participant ,
Jul 03, 2019 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.

Views

1.6K

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
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 05, 2019 Jul 05, 2019

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

Votes

Translate

Translate
Community Expert ,
Jul 03, 2019 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— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

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
community guidelines
Participant ,
Jul 05, 2019 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!

Votes

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
community guidelines
Community Expert ,
Jul 05, 2019 Jul 05, 2019

Copy link to clipboard

Copied

LATEST

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— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

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
community guidelines
Participant ,
Jul 05, 2019 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.

Votes

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
community guidelines