monk / HF_AUTH.md
hf-actions
Clean commit: remove virtualenv and large files
ca2863a
# Hugging Face Space authentication (quick guide)
This repo can be pushed to a Hugging Face Space. Below are minimal steps to authenticate and configure your local folder so `git push` to the Space works.
1) Install the CLI (in your venv)
```powershell
pip install --upgrade huggingface_hub
# optional CLI helper
pip install --upgrade huggingface-hub[cli]
```
2) Login interactively (recommended)
```powershell
huggingface-cli login
# then paste your HF token when prompted
```
3) Or set token in `.env` (non-interactive)
Add one of these lines to your `.env` (already used by helper scripts):
```
HF_TOKEN=hf_xxx...
HUGGINGFACEHUB_API_TOKEN=hf_xxx...
```
4) Use the helper script to configure git remote (optional)
Run in repo root (will print suggested remote and can add it):
```powershell
python hf_auth_setup.py
```
Or manually add remote (replace `<token>`, `<username>`, `<repo>`):
```powershell
git remote remove origin --no-optional || true
git remote add origin https://<token>@huggingface.co/spaces/<username>/<repo>.git
git push -u origin main
```
Note: embedding the token in the remote URL is convenient but the token will be visible in your local git config. Use `huggingface-cli login` or a credential helper for more secure usage.
5) Space runtime Secrets
In the Hugging Face Space UI set the following Secrets (Settings → Secrets):
- `FB_PAGE_ACCESS_TOKEN`
- `FB_PAGE_ID`
- `REPLICATE_API_TOKEN`
- `OPENAI_API_KEY` (if used)
- `RUN_DAILY_REPLICATE` (set to `true` to enable scheduled runs)
6) Troubleshooting
- If `git push` fails with 403, verify the token scope and that the token is valid.
- You can create a new token at: https://huggingface.co/settings/tokens (grant `read` and `write` as needed for repo creation/push).