검색
검색어 지우기
검색 닫기
Google 앱
기본 메뉴
요청하신 페이지는 현재 사용 중인 언어로 제공되지 않습니다. Chrome에 내장된 번역 기능을 사용하면 어떤 웹페이지라도 원하는 언어로 즉시 번역할 수 있습니다.

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 API 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.