Zum Verständnis:
- Der (neue) Token wird in der Antwort als Cookie mitgesendet?
- Dieser ändert sich automatisch alle 15min, hat also auch nur eine begrenzte Gültigkeit?
In diesem Fall müsste auch regelmäßig eine Anfrage gestellt werden, da sonst kein gültiger Token mehr vorliegt.
Ich würde an die Sache so herangehen: Den Token nach dem Request merkt man sich in einer Flow- oder Globalvariable, und gibt dieses dann in jeder neuen Anfrage wieder in msg.header
.
Hier ein grobes Beispiel:
[{"id":"acc4c177.aeb45","type":"inject","z":"9d626f16.d345a8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":220,"wires":[["4a456cd5.2f2afc"]]},{"id":"aa912351.fbfc8","type":"http request","z":"9d626f16.d345a8","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://s-o-b.eu/home/","tls":"","persist":false,"proxy":"","authType":"bearer","x":530,"y":220,"wires":[["c4dbaeab.2a5598","8e76f529.e3c24"]]},{"id":"36393bb1.09088c","type":"change","z":"9d626f16.d345a8","name":"","rules":[{"t":"set","p":"token","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":220,"wires":[["b6642d24.e7228"]]},{"id":"c4dbaeab.2a5598","type":"function","z":"9d626f16.d345a8","name":"Token","func":"let token = msg.responseCookies.sob_token.value; \n\nflow.set('token', token);\n\nmsg.payload = token; \n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":690,"y":220,"wires":[["36393bb1.09088c","e8b2f664.65abc"]]},{"id":"b6642d24.e7228","type":"debug","z":"9d626f16.d345a8","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1180,"y":220,"wires":[]},{"id":"8e76f529.e3c24","type":"debug","z":"9d626f16.d345a8","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"true","targetType":"full","x":710,"y":160,"wires":[]},{"id":"e8b2f664.65abc","type":"debug","z":"9d626f16.d345a8","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1000,"y":160,"wires":[]},{"id":"4a456cd5.2f2afc","type":"function","z":"9d626f16.d345a8","name":"Token -> Header","func":"let token = flow.get('token');\n\nmsg.header = {\n 'Authorization': 'Bearer ' + token\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":220,"wires":[["aa912351.fbfc8","8608768d.b91838"]]},{"id":"80fdb59c.dde44","type":"inject","z":"9d626f16.d345a8","name":"setze Token","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"meintoken","payloadType":"str","x":170,"y":140,"wires":[["7f28d489.b1a094"]]},{"id":"7f28d489.b1a094","type":"change","z":"9d626f16.d345a8","name":"","rules":[{"t":"set","p":"token","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":140,"wires":[[]]},{"id":"8608768d.b91838","type":"debug","z":"9d626f16.d345a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":490,"y":300,"wires":[]}]
Der Token für die Erstanfrage muss mit dem Inject-node "setze Token" manuell gesetzt werden.