PISTE OAuth
The Legifrance API is hosted behind the PISTE portal (https://piste.gouv.fr), which requires OAuth 2.0 authentication in client credentials mode.
-
The user creates a PISTE account and subscribes to the Legifrance API — see
/en/operations/create-piste-account. -
PISTE returns a
client_id/client_secretpair. -
On the first API call,
AuthenticationManager:- POSTs
client_id+client_secret+grant_type=client_credentialsscope=openid(form-url-encoded) totoken_url(the PISTE prod OAuth endpoint by default; sandbox:https://sandbox-oauth.piste.gouv.fr/api/oauth/token);
- receives an
access_tokenwith an expiration (typically 3600 s); - attaches
Authorization: Bearer <token>to subsequent calls.
Official reference: Légifrance API usage examples (DILA) §1 — archived copy in
raw/legifrance/. - POSTs
-
Before every
call_api/get, the manager checks token freshness and refreshes it when needed.
Two URLs, two roles
Section titled “Two URLs, two roles”token_url→ PISTE endpoint that issues the token.api_url→ base URL of the Legifrance business endpoints (search, consult).
Both are configurable via ApiConfig;
defaults point at prod.
On failure
Section titled “On failure”401on token request → invalid credentials or expired API subscription on PISTE.429on business calls → PISTE rate limiting;LegifranceClientusestenacityfor retry with back-off. Exact quotas are visible in the PISTE console and can change at any time — see/en/concepts/api-terms-and-quotas.