API Ecowatt über Node-Red zu Gladys

Ich möchte die neue Ecowatt-API (Catalogue API - API Data RTE) in Gladys integrieren.
Diese API ist über ein temporäres Bearer-Token zugänglich, das alle 2 Stunden erneuert werden muss.

Über Node-red kann man das Token mit einer HTTP-Anfrage abrufen und dann manuell in eine neue HTTP-Anfrage einfügen, um den Payload der API zu erhalten.
Diese Lösung funktioniert gut, ist aber nicht sehr praktisch!

Ich habe daher (ohne Erfolg) nach einer Lösung gesucht, um diese zweite Anfrage zu automatisieren, indem eine Variable injiziert wird, die dem alle 2 Stunden aktualisierten Token entspricht.
Ich denke, man muss eine Funktion verwenden, aber ich komme nicht auf die richtigen Header der Anfrage.

Falls ein Node-red-Spezialist die Lösung hat, bin ich interessiert.
Vielen Dank im Voraus.
jparbel

Das ist eine OAuth2-Authentifizierung, es gibt Bibliotheken, um dieses Protokoll zu verwalten.

EDIT: Ich habe das gerade erfolgreich getestet

Ein Beispiel-Flow

[
    {
        "id": "eee1757110226f86",
        "type": "tab",
        "label": "Ecowatts -> Gladys",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "27ed541908cb256d",
        "type": "oauth2",
        "z": "eee1757110226f86",
        "name": "",
        "container": "oauth2Response",
        "grant_type": "client_credentials",
        "access_token_url": "https://digital.iservices.rte-france.com/token/oauth/",
        "authorization_endpoint": "",
        "redirect_uri": "/oauth2/redirect_uri",
        "open_authentication": "",
        "username": "",
        "password": "",
        "client_id": "XXXXXXXXXXXXXXXXXXX",
        "client_secret": "XXXXXXXXXXXXXXXX",
        "scope": "",
        "rejectUnauthorized": true,
        "headers": {},
        "x": 250,
        "y": 60,
        "wires": [
            [
                "e54c33cdc4a66e73"
            ]
        ]
    },
    {
        "id": "5c8888796344fe7e",
        "type": "debug",
        "z": "eee1757110226f86",
        "name": "debug 2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 680,
        "y": 60,
        "wires": []
    },
    {
        "id": "4141ecf227805b07",
        "type": "inject",
        "z": "eee1757110226f86",
        "name": "Get",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 110,
        "y": 60,
        "wires": [
            [
                "27ed541908cb256d"
            ]
        ]
    },
    {
        "id": "d1cc9455efc67f83",
        "type": "http request",
        "z": "eee1757110226f86",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://digital.iservices.rte-france.com/open_api/ecowatt/v4/signals",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 530,
        "y": 60,
        "wires": [
            [
                "5c8888796344fe7e"
            ]
        ]
    },
    {
        "id": "e54c33cdc4a66e73",
        "type": "function",
        "z": "eee1757110226f86",
        "name": "function 1",
        "func": "msg.headers = {\n    Authorization: \"Bearer \"+msg.oauth2Response.access_token\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 380,
        "y": 60,
        "wires": [
            [
                "d1cc9455efc67f83"
            ]
        ]
    }
]

@VonOx, danke Vincent, es funktioniert super, ist gar nicht kompliziert, wenn man es kann !!