fix(mf): utiliser header apikey: au lieu de Bearer (API Key longue durée)
Some checks are pending
Deploy info-canicule / deploy (push) Waiting to run
Some checks are pending
Deploy info-canicule / deploy (push) Waiting to run
Le portail-api.meteofrance.fr utilise 2 mécanismes d auth différents : - Token OAuth2 court (1h) → header Authorization: Bearer <token> - API Key longue durée → header apikey: <key> On utilise la 2e, donc switch du header. + data-sources/Bulletin_Vigilance_swagger.json (gitignored mais utile en local pour préparer le switch Opendatasoft → Vigilance officielle Météo France). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a849977fcc
commit
5fbbec4902
1 changed files with 3 additions and 1 deletions
|
|
@ -17,11 +17,13 @@ export async function fetchMF(path: string, init: RequestInit = {}): Promise<Res
|
||||||
if (!key) {
|
if (!key) {
|
||||||
throw new Error('METEOFRANCE_API_KEY missing in env');
|
throw new Error('METEOFRANCE_API_KEY missing in env');
|
||||||
}
|
}
|
||||||
|
// Le portail Météo France utilise le header `apikey:` pour les API Keys
|
||||||
|
// longue durée (différent du `Authorization: Bearer` des tokens OAuth2 courts).
|
||||||
return fetch(`${BASE}${path}`, {
|
return fetch(`${BASE}${path}`, {
|
||||||
...init,
|
...init,
|
||||||
headers: {
|
headers: {
|
||||||
...init.headers,
|
...init.headers,
|
||||||
Authorization: `Bearer ${key}`,
|
apikey: key,
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue