How to Keep Your Steam Web API Key Out of Your Game Build
If your Steam Web API key is in your game build, anyone with the build can extract it. Here is how to keep it on a server where it belongs.
Why the key can't live in the client
Everything you ship to players, whether it's a Unity build, a Godot export, an Electron wrapper or a web game, can be inspected. Strings in compiled C# assemblies are easy to read with common decompilers, and JavaScript bundles are plain text. Obfuscation slows people down but does not hide a secret that the program itself needs to read.
Valve's Steamworks documentation makes the distinction clear: a regular user Web API key is tied to a Steam account, while a publisher Web API key (created in Steamworks and tied to your publisher account, used with partner.steam-api.com) can call publisher-only methods for your app, such as granting items or checking ownership. Valve's guidance is that publisher keys must be kept secret and only used from your own servers. If one leaks, someone can make those calls as you.
Common ways the key leaks
- Hard-coded in a script, for example
const string SteamKey = "...", because an AI assistant "made it work". - Stored in a config file (
.json,.env,ScriptableObject,project.godot) that gets packed into the build. - Committed to a public GitHub repo, even if it was deleted in a later commit, since it stays in git history.
- Bundled into a web game via a
VITE_orNEXT_PUBLIC_environment variable, which build tools deliberately expose to the browser.
The fix: a tiny backend that holds the key
Your game talks to your server. Your server talks to Steam. The key exists only in your server's environment variables.
// server.js (Node 18+, e.g. on a serverless function)
// STEAM_PUBLISHER_KEY is set in the host's env settings, never in the repo
export async function verifyPlayer(ticketHex) {
const url = new URL("https://partner.steam-api.com/ISteamUserAuth/AuthenticateUserTicket/v1/");
url.searchParams.set("key", process.env.STEAM_PUBLISHER_KEY);
url.searchParams.set("appid", process.env.STEAM_APP_ID);
url.searchParams.set("ticket", ticketHex);
url.searchParams.set("identity", "my-game-backend"); // must match the client
const res = await fetch(url);
const data = await res.json();
const p = data?.response?.params;
if (!p || p.result !== "OK") throw new Error("Invalid ticket");
return p.steamid; // trusted SteamID
}
Verify players with auth tickets, not SteamIDs
Never let the client simply send "my SteamID is X". Anyone can send any number. Instead, the client asks Steam for a ticket (in the Steamworks SDK, ISteamUser::GetAuthTicketForWebApi with an identity string), sends the hex-encoded ticket to your backend, and the backend validates it with AuthenticateUserTicket as shown above. Per Valve's docs, the identity parameter must match the string the client passed to GetAuthTicketForWebApi, and this call uses a publisher key, so it must run on a secure server. (Game servers can also call it on api.steampowered.com with a user Web API key, with rate limits.) Only then do you trust the SteamID.
If your key already leaked
- Revoke or regenerate the key in Steamworks (or on the Steam Web API key page for user keys) right away.
- Remove it from code and move it to server environment variables.
- Clean it from git history with a tool like
git filter-repo. Rotating the key matters more, since forks and clones may already have it. - Check your app for unexpected item grants, ownership changes or other unusual activity.
Prompt to paste into your AI coding tool
Find every place a Steam Web API key or other secret is referenced in this project.
Move all Steam Web API calls to a server-side function that reads the key from an
environment variable. Change the client to send a GetAuthTicketForWebApi ticket to
that function instead of a SteamID. Do not put any secret in client code or build files.
Want this checked automatically?
BossCheck is a security scanner for indie games built with AI tools. It's in pre-launch: join the waitlist for early access.
Join the waitlist →FAQ
Can I obfuscate my Steam API key instead of moving it to a server?
No. If the game can read the key, so can anyone who runs or unpacks the game. Obfuscation only slows extraction. Keep the key on a server.
Is the Steam App ID secret?
No. Your App ID is public. The Web API key is the secret.
What's the difference between a user key and a publisher key?
A user Web API key is tied to a single Steam account and calls public methods. A publisher key is created in Steamworks and can call protected methods for your app on partner.steam-api.com. Both should stay out of client builds, but a leaked publisher key is far more dangerous.
How do I know which SteamID is really playing?
Have the client request an auth ticket with GetAuthTicketForWebApi and validate it on your server with ISteamUserAuth/AuthenticateUserTicket.
More guides
- Firebase and Supabase Security Rules for Multiplayer Games
- Never Trust the Client: Stopping Cheaters in Vibe-Coded Multiplayer Games
- Security Checklist Before Shipping a Game Built with Cursor, Claude or Lovable
- Is Code from Cursor, Lovable or Claude Secure? What to Check Before You Ship
- How to Protect API Keys in a Unity Game
- How to Stop Players Editing Browser Game Saves to Unlock Paid Items
- Securing Godot 4 Multiplayer: RPCs, Authority and Server-Side Validation
- Is My Vibe-Coded Game Safe? A Free 10-Minute Security Self-Check
- Stop Bots and Scripts from Breaking Your Game Economy Before a Steam Launch