Hard-coded API keys and secrets
A key, password or token written directly into source code. Anyone who can read the code or its repository can steal it, and deleting the file later does not remove it from the history.
Understanding Hard-coded API keys and secrets in VCE Software Development U4O2
What it does: This removes the file only from the latest version. Earlier commits still contain the key, so anyone can view the history and recover it. A password written as a string in source code is committed with the code, so everyone who can read the repository can see and steal it. Putting the key in a variable does not hide it. Anyone who can read app.py can read the key, so it is a hard-coded secret. Threat actors run automated tools that scan public repositories for leaked keys. A leaked key can be used within minutes of being pushed. Once a secret has been exposed it must be treated as compromised. Only revoking it and issuing a new one stops it being misused.
Common mistakes: The API key is typed straight into the source code, so anyone who can read the code or its repository can steal it. It should be read from an environment variable: key = os.environ["API_KEY"]. Automated bots constantly scan public repositories for leaked keys, often within minutes of a push. The line should say that bots scan public code for keys.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 23–47) and word search (Modules 1–47).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
hard-coded secretFill in the Blanks
Spot the Error
Student with a class code? Join your class →