Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Keep secret API keys out of browser code, URLs, and source repositories. Store them where only the application component that needs them can access them, restrict what they can do, and monitor their use. If a key is exposed, revoke or rotate it promptly, move applications to a replacement, and check for suspicious activity.

An API key is a credential, much like a house key—but first check which doors it opens. Some keys associate requests with a project for billing or quota without identifying a user. Others, such as Google Cloud authorization keys bound to a service account, can act as that account. The possible damage depends on the credential’s actual permissions, not just its name.

What does an API key allow someone to do?

An API key is a value an application presents when making requests to an API. Treat it as a credential: anyone who obtains it may be able to use it, subject to the provider’s restrictions and the authority attached to that credential.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not assume all API keys grant the same access. Google Cloud distinguishes standard API keys from authorization keys. A standard key associates a request with a project for billing and quota but does not itself identify a principal. An authorization key bound to a service account acts as that service account. In the second case, the service account’s authority matters to the key’s risk.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Before deciding where to put a key or how urgently to respond to exposure, establish what it can access. Check which APIs it can call, what account or project it is associated with, and which applications or origins are permitted to use it. The provider’s terminology and controls differ, so consult the documentation for the particular credential and service.

How do I keep my API key secret?

Keep secret keys on a server-side component, restrict their permitted use, and avoid copying them into places that are widely visible or automatically recorded. A secret embedded in a client application is not secret from the people who run that application.

Keep secrets out of client code

Do not embed a secret API key in a website’s frontend or another client application. Code delivered to a browser or other user-controlled device can be inspected, so hiding the key in a variable or bundling step does not make it confidential. Where the API design permits, have a server-side component hold the key and add it to requests on the application’s behalf.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This changes the handling path: the client sends its request to your server, and the server makes the API request using the secret. That does not eliminate the need to control access to the server or limit the key’s authority, but it keeps the secret out of the client code. If a particular API requires a client-visible key, use the provider’s supported application restrictions and avoid treating that key as a general-purpose secret.

Restrict what can use the key

Where the provider supports them, apply both API restrictions and application restrictions. API restrictions limit which APIs a key can call; application restrictions limit which websites, IP addresses, or applications can use it. These controls reduce the ways a copied key can be used, but they do not make it safe to publish a secret in code.

Google Cloud warns that unrestricted API keys are insecure and recommends applying both kinds of restrictions. Remove keys that are no longer needed, and monitor API usage so that unexpected use can be investigated.

Keep keys out of URLs and repositories

Avoid putting API keys in URL query parameters when the provider offers a safer header or client-library method. URLs can be recorded or scanned, which can expose credentials. Google Cloud specifically cautions that query parameters put a key in the URL and expose it to theft through URL scans.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not commit secrets to a source repository. Use secret scanning or an equivalent detection step, including in development or CI workflows where appropriate. AWS guidance recommends scanning repositories and integrating detection into development or CI/CD processes. A scan helps find accidental exposure; it is not a substitute for keeping secrets out of commits.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Where should I store an API key?

Prefer an identity or short-lived credential when the platform supports one. If a long-lived secret is necessary, store it using a controlled mechanism that limits who can retrieve it and supports auditing and rotation.

A managed secrets service can centralize storage and provide controlled access through an API. AWS describes centralized storage, auditability, and automated distribution or rotation as benefits of secrets management. Choose a method that fits the credential and application rather than assuming every secret belongs in the same place.

There is an important platform-specific qualification: Google Cloud’s service account key guidance says it does not recommend storing and rotating service account keys in Google Secret Manager when an application already has a Google-recognized identity. In that situation, the identity can authenticate directly. This guidance concerns Google Cloud service account keys and applications with a recognized identity; it is not a general objection to secret managers for other application secrets.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For any storage method, consider who or what can read the secret, how that access is audited, and how the application receives updates when the secret changes. Keep access limited to the components that need the credential. If the application can use a workload identity or temporary credential instead of a long-lived key, AWS recommends preferring that approach where feasible.

Should I rotate API keys?

Yes, rotate keys when needed and retire credentials that are no longer in use, but use a sequence that avoids interrupting applications. The right schedule depends on the credential and provider: Google Cloud’s API key best-practices guidance says to rotate keys periodically but does not set a universal interval.

Use a planned replacement sequence

  1. Create a replacement key with the same restrictions as the existing key. Do not unintentionally give the new credential broader API or application access.

  2. Update each application or workload that uses the old key. Check all consumers rather than assuming there is only one.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  3. Verify that the updated applications work with the replacement key. Investigate failures before removing the credential they still depend on.

    Rank #3
    Sale
    Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
    • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
    • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
    • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
    • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
    • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
  4. Delete the old key after consumers have moved. Deleting it too early can interrupt service; leaving an obsolete key active longer than needed increases the number of credentials that must be protected.

Google Cloud gives this create, update, then delete sequence for API key rotation. Follow the provider’s procedure for other credential types rather than assuming that every key has the same rotation process.

Do not generalize the 90-day recommendation

Google Cloud recommends rotating service account keys at least every 90 days and rotating immediately if compromise is suspected. That interval is guidance for Google Cloud service account keys, not a universal schedule for all API keys. Apply the schedule and procedure documented for the credential you actually use.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What should I do if I accidentally committed an API key?

Treat a committed key as exposed, even if you remove it from the latest version of the file. Revoke or rotate the credential promptly, update applications to use a replacement, and inspect usage for suspicious activity.

  1. Revoke or rotate the exposed credential. Use the provider’s control plane to disable the old key or replace it. AWS advises immediately rotating or revoking an exposed credential.

  2. Move application consumers to the replacement. Update the systems that depended on the exposed key and verify they work before retiring any replacement credential you still need.

  3. Review usage. Check available API usage information for unexpected activity. If the key could act as an account or service identity, consider its authority when deciding what activity to investigate.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  4. Remove the secret from repository history where applicable. A change to the current file does not erase earlier commits containing the key. AWS guidance for exposed credentials includes removing secrets from repository history. Follow your repository host’s procedure and coordinate with collaborators, since rewriting history affects the shared repository.

    Rank #4
    Sale
    UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
    • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
    • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
    • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
    • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
    • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
  5. Look for the same secret elsewhere. Check other files, branches, or application configurations where the credential may have been copied, then remove those uses and add detection to reduce the chance of another accidental commit.

Do not treat deleting a line, making a repository private, or removing a visible commit as proof that an exposed credential is safe to keep using. The priority is to invalidate the credential; repository cleanup addresses the copies left behind.

Which credential approach should I choose?

Compare approaches by lifetime, scope, handling path, and operational controls—not by a blanket claim that one storage option is always safest.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Approach Credential lifetime Scope and handling Operational considerations
Long-lived API key Remains valid until it is rotated or revoked according to the provider’s controls. Restrict the APIs and applications, origins, or addresses permitted to use it where supported. Keep it out of client code and URL parameters. Store with controlled access, monitor use, and plan how to rotate it.
Short-lived or temporary credential Temporary rather than long-lived. Use when the platform supports it and the application can obtain it through an appropriate identity or workflow. AWS recommends replacing long-term credentials with short-term ones where feasible.
Workload identity Avoids relying on a stored long-lived key when the platform provides a recognized identity for the workload. The application authenticates through its identity instead of carrying a service account key. Google Cloud recommends direct authentication through a recognized identity rather than storing and rotating a service account key in Secret Manager in that situation.

The table describes broad handling choices, not interchangeable products or universal provider features. A credential that is short-lived can still be misused while valid, and a restricted key still needs careful handling. Start with the least persistent credential the platform supports, then limit the authority and exposure of anything that remains necessary.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What habits make key handling easier to maintain?

Security controls work better when each credential has a clear owner and a deliberate lifecycle. Use these checks when adding or reviewing a key:

Exact controls differ by provider, product, and credential. Use the documentation for the specific API key or identity you operate; the Google Cloud and AWS recommendations above are scoped to their own guidance, not a vendor-neutral standard.

Frequently Asked Questions

Is an API key the same as a password?

Both are credentials that should be protected, but an API key is generally presented by software when it calls an API. Its permissions and purpose depend on how the provider issued and configured it, so do not infer its authority from the word “key” alone.

Can I share an API key with a contractor or teammate?

Avoid distributing a shared secret more widely than necessary. Ask whether the person or workload can use an individual identity or a separately scoped credential instead; separate credentials make it easier to limit access and revoke one without disrupting everyone else.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Will making a repository private protect a key that was committed?

No. Changing repository visibility does not invalidate a credential or remove earlier commits that contain it. Treat the key as exposed and revoke or rotate it, then handle repository history cleanup separately.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.