HF_TOKEN stored anywhere.
The exchanged token covers less than a user access token. Pick the flavor that matches what your task does:
A CI/CD identity token can’t read your private repos or write anything; use a repo publisher for those (security model).
Follow the OIDC prerequisites, then go to the OIDC page for your environment and copy the issuer URL and subject.
Configure Hugging Face
Add a CI/CD identity or a repo trusted publisher, as in the table above. The settings list presets for CI providers, but any OIDC-compliant provider works:- Issuer: the issuer URL copied from the dashboard.
- Claims:
subset to the complete subject copied from the dashboard. Hugging Face matches claims exactly, so each environment needs its own identity or publisher.
aud is https://huggingface.co.
Call Hugging Face in your task
HF_TOKEN. resource is your Hugging Face username for a CI/CD identity, or the repo (namespace/name, datasets/namespace/name) for a repo publisher:
/trigger/hugging-face-inference.ts
400 with invalid_grant when the issuer, subject or audience doesn’t match the identity or publisher. The token lasts 60 minutes with no refresh token, so exchange again for longer work.
Remove the old credential
Once runs in every deployed environment authenticate this way, deleteHF_TOKEN, HUGGING_FACE_HUB_TOKEN and HUGGINGFACEHUB_API_TOKEN from those environments on the Environment Variables page, then revoke the access token in your Hugging Face token settings.
Local Development runs can’t mint OIDC tokens. Use your own Hugging Face token there when ctx.environment.type === "DEVELOPMENT".
