Module 5 Resources#
Setting Up Your Hugging Face Token in Google Colab#
Some notebooks download models from Hugging Face. To avoid download limits and errors, each student must use their own Hugging Face Read token.
This is free, safe, and takes about 2–3 minutes.
Step 1: Create a Hugging Face token#
Click New token
Choose:
Name: anything (e.g.
colab)Role: Read
Click Create token
Copy the token (you won’t see it again)
Do not share your token with anyone.
Step 2: Add the token to Colab (Key icon)#
Open the notebook in Google Colab
Look at the left sidebar
Click the Secrets icon (key symbol)
Click “Add a new secret”
Enter:
Name:
HF_TOKENValue: paste your token
Turn ON: “Available to all notebooks”
Restart the runtime
There is no “Runtime → Secrets” menu anymore — the key icon is the correct place.
Step 3: Verify it worked#
Run this cell in the notebook:
import os
assert "HF_TOKEN" in os.environ, "HF_TOKEN not found"
print("HF_TOKEN loaded successfully")
If you see:
HF_TOKEN loaded successfully
you’re done!
Common issues & fixes#
Secrets icon missing?
Make sure you are using Google Colab (not local Jupyter)
Click the menu icon to expand the sidebar
Try zooming out slightly in your browser
Still getting warnings?
Restart the runtime again
Re-check the secret name is exactly
HF_TOKEN(case-sensitive)
Important rules#
Do not hard-code tokens in code cells
Do not share tokens
Do not upload tokens to GitHub
Use Read access only