How do I securely use Google API Keys

Jack O

So I am using the Google Maps API on my first project that I am doing... So yes I am new and I am sorry if this is basic or obvious but I haven't been able to find a clear answer or direction. Below is the documentation I found from Google about securely using the API Key.


Best practices for securely using API keys

When you use API keys in your applications, take care to keep them secure. Publicly exposing your credentials can result in your account being compromised, which could lead to unexpected charges on your account. To keep your API keys secure, follow these best practices:

Do not embed API keys directly in code: API keys that are embedded in code can be accidentally exposed to the public—for example, if you forget to remove the keys from code that you share. Instead of embedding your API keys in your applications, store them in environment variables or in files outside of your application's source tree. Do not store API keys in files inside your application's source tree: If you store API keys in files, keep the files outside your application's source tree to help ensure your keys do not end up in your source code control system. This is particularly important if you use a public source code management system such as GitHub. Restrict your API keys to be used by only the IP addresses, referrer URLs, and mobile apps that need them: By restricting the IP addresses, referrer URLs, and mobile apps that can use each key, you can reduce the impact of a compromised API key. You can specify the hosts and apps that can use each key from the console by opening the Credentials page and then either creating a new API key with the settings you want, or editing the settings of an API key. Delete unneeded API keys: To minimize your exposure to attack, delete any API keys that you no longer need. Regenerate your API keys periodically: You can regenerate API keys from the Cloud Platform Console Credentials page by clicking Regenerate key for each key. Then, update your applications to use the newly-generated keys. Your old keys will continue to work for 24 hours after you generate replacement keys. Review your code before publicly releasing it: Ensure that your code does not contain API keys or any other private information before you make your code publicly available.


Now my problem is I can't figure out how to incorporate the Google Map on my website without directly putting it in the code. Right now my API is in my index.html like this:

<script async defer
    src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
</script>

But again this is directly in my code for the world to see which I believe is the wrong way.

geocodezip

For the Google Maps Javascript API v3 the keys must be public on you page. The applicable text is:

Restrict your API keys to be used by only the IP addresses, referrer URLs, and mobile apps that need them

Go to the Google API Console and generate a key, restricting it to URLs that you own (or want to put maps on) to prevent quota "theft".

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I use Gemfury tokens securely in CircleCI?

From Dev

How do we deliver the API keys and secret tokens securely over the wire to the users?

From Dev

How to use two google api keys simultaneously?

From Dev

How do I setup OpenVPN so I can securely use the internet from an unsecured hotspot?

From Dev

How do I setup OpenVPN so I can securely use the internet from an unsecured hotspot?

From Dev

How do I use the Google Calendar API with Java?

From Dev

How do I use an API key with Google Static Maps?

From Dev

How do I use the FreeBusyResponse in Google Calendar java API?

From Dev

How do I use Google's AutoComplete locations API?

From Dev

How can I securely store my AWS keys for an app on AppHarbor?

From Dev

How to securely download rpmfusion keys

From Dev

How to safely store Google Api keys with rails and use them in scripts?

From Dev

How Can I Use the Android KeyStore to securely store arbitrary strings?

From Dev

How can I send data to an API via the internet securely?

From Dev

Securely Saving API Keys In Android (flutter) Apps

From Dev

How do I securely configure a CI server to digitally sign binaries?

From Dev

How do I securely handle passwords in a Java Servlet Filter?

From Dev

How do I securely save a variable not affected by render?

From Dev

How do I securely store and manage 180 passwords?

From Dev

How do I securely extract an untrusted tar file?

From Dev

How do I securely download files in shell scripting?

From Dev

How do I set up ssh keys in Google Compute Engine?

From Dev

How do I use numbers in a list as keys for my dictionary in Python?

From Dev

How do I use multiple SSH keys on GitHub?

From Dev

How do I use the function keys on Windows 8?

From Dev

How do I use numbers in a list as keys for my dictionary in Python?

From Dev

How do I use Composer to setup google-api-php-client?

From Dev

How do I use oauth2 and refresh tokens with the google api?

From Dev

How do I use Google Translate API from a java program on a client?

Related Related

  1. 1

    How do I use Gemfury tokens securely in CircleCI?

  2. 2

    How do we deliver the API keys and secret tokens securely over the wire to the users?

  3. 3

    How to use two google api keys simultaneously?

  4. 4

    How do I setup OpenVPN so I can securely use the internet from an unsecured hotspot?

  5. 5

    How do I setup OpenVPN so I can securely use the internet from an unsecured hotspot?

  6. 6

    How do I use the Google Calendar API with Java?

  7. 7

    How do I use an API key with Google Static Maps?

  8. 8

    How do I use the FreeBusyResponse in Google Calendar java API?

  9. 9

    How do I use Google's AutoComplete locations API?

  10. 10

    How can I securely store my AWS keys for an app on AppHarbor?

  11. 11

    How to securely download rpmfusion keys

  12. 12

    How to safely store Google Api keys with rails and use them in scripts?

  13. 13

    How Can I Use the Android KeyStore to securely store arbitrary strings?

  14. 14

    How can I send data to an API via the internet securely?

  15. 15

    Securely Saving API Keys In Android (flutter) Apps

  16. 16

    How do I securely configure a CI server to digitally sign binaries?

  17. 17

    How do I securely handle passwords in a Java Servlet Filter?

  18. 18

    How do I securely save a variable not affected by render?

  19. 19

    How do I securely store and manage 180 passwords?

  20. 20

    How do I securely extract an untrusted tar file?

  21. 21

    How do I securely download files in shell scripting?

  22. 22

    How do I set up ssh keys in Google Compute Engine?

  23. 23

    How do I use numbers in a list as keys for my dictionary in Python?

  24. 24

    How do I use multiple SSH keys on GitHub?

  25. 25

    How do I use the function keys on Windows 8?

  26. 26

    How do I use numbers in a list as keys for my dictionary in Python?

  27. 27

    How do I use Composer to setup google-api-php-client?

  28. 28

    How do I use oauth2 and refresh tokens with the google api?

  29. 29

    How do I use Google Translate API from a java program on a client?

HotTag

Archive