<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Thema "Betreff: How to avoid sudden death after 180 days – automatic initialization and refresh of the access and refresh tokens in Node-Red applications" in The Viessmann API</title>
    <link>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/266271#M984</link>
    <description>&lt;P&gt;Ich habe hier nochmal das korrekte JSON per cut&amp;amp;paste eingefügt. Per pdf scheint das nicht zu funktionieren.&lt;/P&gt;&lt;P&gt;Sorry nochmal für die Verwirrung.&lt;/P&gt;&lt;P&gt;VG&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;P&gt;+++++++++++++++++++++++++++++++++++++++++++++++&lt;/P&gt;&lt;P&gt;[&lt;BR /&gt;{&lt;BR /&gt;"id": "9d0e5593d53b55d0",&lt;BR /&gt;"type": "debug",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "complete msg object",&lt;BR /&gt;"active": true,&lt;BR /&gt;"tosidebar": true,&lt;BR /&gt;"console": false,&lt;BR /&gt;"tostatus": false,&lt;BR /&gt;"complete": "true",&lt;BR /&gt;"targetType": "full",&lt;BR /&gt;"statusVal": "",&lt;BR /&gt;"statusType": "auto",&lt;BR /&gt;"x": 1000,&lt;BR /&gt;"y": 340,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "d6e3257c9c2d54ad",&lt;BR /&gt;"type": "http request",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "1st time Token Request",&lt;BR /&gt;"method": "POST",&lt;BR /&gt;"ret": "obj",&lt;BR /&gt;"paytoqs": "ignore",&lt;BR /&gt;"url": "&lt;A href="https://iam.viessmann.com/idp/v2/token" target="_blank"&gt;https://iam.viessmann.com/idp/v2/token&lt;/A&gt;",&lt;BR /&gt;"tls": "",&lt;BR /&gt;"persist": false,&lt;BR /&gt;"proxy": "",&lt;BR /&gt;"insecureHTTPParser": false,&lt;BR /&gt;"authType": "",&lt;BR /&gt;"senderr": false,&lt;BR /&gt;"headers": [],&lt;BR /&gt;"x": 730,&lt;BR /&gt;"y": 460,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"9d0e5593d53b55d0",&lt;BR /&gt;"a15685d5a21c73f4",&lt;BR /&gt;"4cd4555c4b8a54e4",&lt;BR /&gt;"e3bde0eca33a67c8"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "46386b17e466c5b4",&lt;BR /&gt;"type": "function",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "set payload &amp;amp; headers",&lt;BR /&gt;"func": "msg.payload = `grant_type=authorization_code&amp;amp;client_id=YOURCLIENTID&amp;amp;redirect_uri=&lt;A href="http://localhost:1880/authcode&amp;amp;code_verifier=2e21faa1-db2c-4d0b-a10f-575fd372bc8c-575fd372bc8c&amp;amp;code=${msg.payload.code" target="_blank"&gt;http://localhost:1880/authcode&amp;amp;code_verifier=2e21faa1-db2c-4d0b-a10f-575fd372bc8c-575fd372bc8c&amp;amp;code=${msg.payload.code&lt;/A&gt;}`;\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/x-www-form-urlencoded';\n\nreturn msg;",&lt;BR /&gt;"outputs": 1,&lt;BR /&gt;"noerr": 0,&lt;BR /&gt;"initialize": "",&lt;BR /&gt;"finalize": "",&lt;BR /&gt;"libs": [],&lt;BR /&gt;"x": 480,&lt;BR /&gt;"y": 460,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"d6e3257c9c2d54ad"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "d5abc46074c395a0",&lt;BR /&gt;"type": "inject",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "",&lt;BR /&gt;"props": [&lt;BR /&gt;{&lt;BR /&gt;"p": "payload"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"p": "topic",&lt;BR /&gt;"vt": "str"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"repeat": "",&lt;BR /&gt;"crontab": "",&lt;BR /&gt;"once": true,&lt;BR /&gt;"onceDelay": 0.1,&lt;BR /&gt;"topic": "",&lt;BR /&gt;"payload": "",&lt;BR /&gt;"payloadType": "date",&lt;BR /&gt;"x": 290,&lt;BR /&gt;"y": 240,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"c765f5d53247981e"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "595c3f168551465e",&lt;BR /&gt;"type": "debug",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Request Result",&lt;BR /&gt;"active": true,&lt;BR /&gt;"tosidebar": true,&lt;BR /&gt;"console": false,&lt;BR /&gt;"tostatus": false,&lt;BR /&gt;"complete": "payload",&lt;BR /&gt;"targetType": "msg",&lt;BR /&gt;"statusVal": "",&lt;BR /&gt;"statusType": "auto",&lt;BR /&gt;"x": 620,&lt;BR /&gt;"y": 240,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "904e0e39a0436cf7",&lt;BR /&gt;"type": "http in",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "",&lt;BR /&gt;"url": "/authcode",&lt;BR /&gt;"method": "get",&lt;BR /&gt;"upload": false,&lt;BR /&gt;"swaggerDoc": "",&lt;BR /&gt;"x": 240,&lt;BR /&gt;"y": 360,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"beb9836fcb2f735c",&lt;BR /&gt;"1282ee44e06b324d",&lt;BR /&gt;"46386b17e466c5b4"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "beb9836fcb2f735c",&lt;BR /&gt;"type": "debug",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "msg.payload.code",&lt;BR /&gt;"active": true,&lt;BR /&gt;"tosidebar": true,&lt;BR /&gt;"console": false,&lt;BR /&gt;"tostatus": false,&lt;BR /&gt;"complete": "payload.code",&lt;BR /&gt;"targetType": "msg",&lt;BR /&gt;"statusVal": "",&lt;BR /&gt;"statusType": "auto",&lt;BR /&gt;"x": 470,&lt;BR /&gt;"y": 320,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "1282ee44e06b324d",&lt;BR /&gt;"type": "http response",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Reponse",&lt;BR /&gt;"statusCode": "200",&lt;BR /&gt;"headers": {},&lt;BR /&gt;"x": 440,&lt;BR /&gt;"y": 360,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "13da70accda71262",&lt;BR /&gt;"type": "comment",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Generate authorization code",&lt;BR /&gt;"info": "",&lt;BR /&gt;"x": 320,&lt;BR /&gt;"y": 200,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "c765f5d53247981e",&lt;BR /&gt;"type": "http request",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "",&lt;BR /&gt;"method": "GET",&lt;BR /&gt;"ret": "txt",&lt;BR /&gt;"paytoqs": "ignore",&lt;BR /&gt;"url": "&lt;A href="https://iam.viessmann.com/idp/v2/authorize?client_id=a602c3ccb073b72740420f03ad1b21f3&amp;amp;redirect_uri=http://localhost:1880/authcode&amp;amp;response_type=code&amp;amp;code_challenge=2e21faa1-db2c-4d0b-a10f-575fd372bc8c-575fd372bc8c&amp;amp;scope=IoT%20User%20offline_access" target="_blank"&gt;https://iam.viessmann.com/idp/v2/authorize?client_id=a602c3ccb073b72740420f03ad1b21f3&amp;amp;redirect_uri=http://localhost:1880/authcode&amp;amp;response_type=code&amp;amp;code_challenge=2e21faa1-db2c-4d0b-a10f-575fd372bc8c-575fd372bc8c&amp;amp;scope=IoT%20User%20offline_access&lt;/A&gt;",&lt;BR /&gt;"tls": "",&lt;BR /&gt;"persist": false,&lt;BR /&gt;"proxy": "",&lt;BR /&gt;"insecureHTTPParser": false,&lt;BR /&gt;"authType": "basic",&lt;BR /&gt;"senderr": false,&lt;BR /&gt;"headers": [],&lt;BR /&gt;"x": 450,&lt;BR /&gt;"y": 240,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"595c3f168551465e"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "296e1357a73c8e32",&lt;BR /&gt;"type": "comment",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Click here --&amp;gt;",&lt;BR /&gt;"info": "",&lt;BR /&gt;"x": 110,&lt;BR /&gt;"y": 240,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "751a30abd962d114",&lt;BR /&gt;"type": "comment",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "after expiry",&lt;BR /&gt;"info": "",&lt;BR /&gt;"x": 100,&lt;BR /&gt;"y": 200,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "a15685d5a21c73f4",&lt;BR /&gt;"type": "debug",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "access_token",&lt;BR /&gt;"active": false,&lt;BR /&gt;"tosidebar": true,&lt;BR /&gt;"console": false,&lt;BR /&gt;"tostatus": false,&lt;BR /&gt;"complete": "payload",&lt;BR /&gt;"targetType": "msg",&lt;BR /&gt;"statusVal": "",&lt;BR /&gt;"statusType": "auto",&lt;BR /&gt;"x": 980,&lt;BR /&gt;"y": 420,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "e3bde0eca33a67c8",&lt;BR /&gt;"type": "debug",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "refresh_token",&lt;BR /&gt;"active": false,&lt;BR /&gt;"tosidebar": true,&lt;BR /&gt;"console": false,&lt;BR /&gt;"tostatus": false,&lt;BR /&gt;"complete": "payload",&lt;BR /&gt;"targetType": "msg",&lt;BR /&gt;"statusVal": "",&lt;BR /&gt;"statusType": "auto",&lt;BR /&gt;"x": 980,&lt;BR /&gt;"y": 380,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "4cd4555c4b8a54e4",&lt;BR /&gt;"type": "change",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "set token flow variables",&lt;BR /&gt;"rules": [&lt;BR /&gt;{&lt;BR /&gt;"t": "set",&lt;BR /&gt;"p": "accessToken",&lt;BR /&gt;"pt": "flow",&lt;BR /&gt;"to": "payload.access_token",&lt;BR /&gt;"tot": "msg"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"t": "set",&lt;BR /&gt;"p": "refreshToken",&lt;BR /&gt;"pt": "flow",&lt;BR /&gt;"to": "payload.refresh_token",&lt;BR /&gt;"tot": "msg"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"action": "",&lt;BR /&gt;"property": "",&lt;BR /&gt;"from": "",&lt;BR /&gt;"to": "",&lt;BR /&gt;"reg": false,&lt;BR /&gt;"x": 1010,&lt;BR /&gt;"y": 460,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"0a5b06420e87d77f"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "3d828c3c867062b0",&lt;BR /&gt;"type": "http request",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Installation ID",&lt;BR /&gt;"method": "GET",&lt;BR /&gt;"ret": "obj",&lt;BR /&gt;"paytoqs": "ignore",&lt;BR /&gt;"url": "&lt;A href="https://api.viessmann.com/iot/v1/equipment/installations" target="_blank"&gt;https://api.viessmann.com/iot/v1/equipment/installations&lt;/A&gt;",&lt;BR /&gt;"tls": "",&lt;BR /&gt;"persist": false,&lt;BR /&gt;"proxy": "",&lt;BR /&gt;"insecureHTTPParser": false,&lt;BR /&gt;"authType": "",&lt;BR /&gt;"senderr": false,&lt;BR /&gt;"headers": [],&lt;BR /&gt;"x": 680,&lt;BR /&gt;"y": 600,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"f32181561f6a81ab"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "0a5b06420e87d77f",&lt;BR /&gt;"type": "function",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Auth Header",&lt;BR /&gt;"func": "var atoken = flow.get('accessToken')\nmsg.headers = {\n Authorization: \"Bearer \"+ atoken\n}\nreturn msg;\n\n",&lt;BR /&gt;"outputs": 1,&lt;BR /&gt;"noerr": 0,&lt;BR /&gt;"initialize": "",&lt;BR /&gt;"finalize": "",&lt;BR /&gt;"libs": [],&lt;BR /&gt;"x": 450,&lt;BR /&gt;"y": 600,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"3d828c3c867062b0"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "d189c65f2d221d39",&lt;BR /&gt;"type": "http request",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Gateway Serial",&lt;BR /&gt;"method": "GET",&lt;BR /&gt;"ret": "obj",&lt;BR /&gt;"paytoqs": "ignore",&lt;BR /&gt;"url": "&lt;A href="https://api.viessmann.com/iot/v1/equipment/gateways" target="_blank"&gt;https://api.viessmann.com/iot/v1/equipment/gateways&lt;/A&gt;",&lt;BR /&gt;"tls": "",&lt;BR /&gt;"persist": false,&lt;BR /&gt;"proxy": "",&lt;BR /&gt;"insecureHTTPParser": false,&lt;BR /&gt;"authType": "",&lt;BR /&gt;"senderr": false,&lt;BR /&gt;"headers": [],&lt;BR /&gt;"x": 680,&lt;BR /&gt;"y": 640,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"a92443f4485556c4"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "f32181561f6a81ab",&lt;BR /&gt;"type": "change",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "set flow.installationID",&lt;BR /&gt;"rules": [&lt;BR /&gt;{&lt;BR /&gt;"t": "set",&lt;BR /&gt;"p": "installationID",&lt;BR /&gt;"pt": "flow",&lt;BR /&gt;"to": "payload.data[0].id",&lt;BR /&gt;"tot": "msg"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"action": "",&lt;BR /&gt;"property": "",&lt;BR /&gt;"from": "",&lt;BR /&gt;"to": "",&lt;BR /&gt;"reg": false,&lt;BR /&gt;"x": 880,&lt;BR /&gt;"y": 600,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"dadfb8ae29d2643b"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "a92443f4485556c4",&lt;BR /&gt;"type": "change",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "set flow.gatewaySerial",&lt;BR /&gt;"rules": [&lt;BR /&gt;{&lt;BR /&gt;"t": "set",&lt;BR /&gt;"p": "gatewaySerial",&lt;BR /&gt;"pt": "flow",&lt;BR /&gt;"to": "payload.data[0].serial",&lt;BR /&gt;"tot": "msg"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"action": "",&lt;BR /&gt;"property": "",&lt;BR /&gt;"from": "",&lt;BR /&gt;"to": "",&lt;BR /&gt;"reg": false,&lt;BR /&gt;"x": 880,&lt;BR /&gt;"y": 640,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"5cfecbbe8f899905"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "dadfb8ae29d2643b",&lt;BR /&gt;"type": "function",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Auth Header",&lt;BR /&gt;"func": "var atoken = flow.get('accessToken')\nmsg.headers = {\n Authorization: \"Bearer \"+ atoken\n}\nreturn msg;\n\n",&lt;BR /&gt;"outputs": 1,&lt;BR /&gt;"noerr": 0,&lt;BR /&gt;"initialize": "",&lt;BR /&gt;"finalize": "",&lt;BR /&gt;"libs": [],&lt;BR /&gt;"x": 450,&lt;BR /&gt;"y": 640,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"d189c65f2d221d39"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "f52e123cdd02a6bc",&lt;BR /&gt;"type": "http request",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "DeviceID",&lt;BR /&gt;"method": "GET",&lt;BR /&gt;"ret": "obj",&lt;BR /&gt;"paytoqs": "ignore",&lt;BR /&gt;"url": "&lt;A href="https://api.viessmann.com/iot/v1/equipment/installations/{{iid}}/gateways/{{gws}}/devices/" target="_blank"&gt;https://api.viessmann.com/iot/v1/equipment/installations/{{iid}}/gateways/{{gws}}/devices/&lt;/A&gt; ",&lt;BR /&gt;"tls": "",&lt;BR /&gt;"persist": false,&lt;BR /&gt;"proxy": "",&lt;BR /&gt;"insecureHTTPParser": false,&lt;BR /&gt;"authType": "",&lt;BR /&gt;"senderr": false,&lt;BR /&gt;"headers": [],&lt;BR /&gt;"x": 660,&lt;BR /&gt;"y": 680,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"e553113d728f21a8"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "e553113d728f21a8",&lt;BR /&gt;"type": "change",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "",&lt;BR /&gt;"rules": [&lt;BR /&gt;{&lt;BR /&gt;"t": "set",&lt;BR /&gt;"p": "deviceID",&lt;BR /&gt;"pt": "flow",&lt;BR /&gt;"to": "payload.data[0].id",&lt;BR /&gt;"tot": "msg"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"action": "",&lt;BR /&gt;"property": "",&lt;BR /&gt;"from": "",&lt;BR /&gt;"to": "",&lt;BR /&gt;"reg": false,&lt;BR /&gt;"x": 870,&lt;BR /&gt;"y": 680,&lt;BR /&gt;"wires": [&lt;BR /&gt;[]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "5cfecbbe8f899905",&lt;BR /&gt;"type": "function",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "extended auth header",&lt;BR /&gt;"func": "//var o = parseFloat(flow.get('2vo1'));\n//var atoken = msg.token\nvar atoken = flow.get('accessToken')\nmsg.headers = {\n Authorization: \"Bearer \"+ atoken\n}\nmsg.iid = flow.get('installationID');\nmsg.gws = flow.get('gatewaySerial');\nreturn msg;\n\n",&lt;BR /&gt;"outputs": 1,&lt;BR /&gt;"noerr": 0,&lt;BR /&gt;"initialize": "",&lt;BR /&gt;"finalize": "",&lt;BR /&gt;"libs": [],&lt;BR /&gt;"x": 480,&lt;BR /&gt;"y": 680,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"f52e123cdd02a6bc"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "27904bd00d57b5f8",&lt;BR /&gt;"type": "comment",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "get tokens 1st time",&lt;BR /&gt;"info": "",&lt;BR /&gt;"x": 290,&lt;BR /&gt;"y": 420,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "5ddbfc6f31907258",&lt;BR /&gt;"type": "comment",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "get/set invariable parameters",&lt;BR /&gt;"info": "",&lt;BR /&gt;"x": 320,&lt;BR /&gt;"y": 540,&lt;BR /&gt;"wires": []&lt;BR /&gt;}&lt;BR /&gt;]&lt;/P&gt;</description>
    <pubDate>Fri, 07 Oct 2022 20:41:57 GMT</pubDate>
    <dc:creator>CaCicala</dc:creator>
    <dc:date>2022-10-07T20:41:57Z</dc:date>
    <item>
      <title>How to avoid sudden death after 180 days – automatic initialization and refresh of the access and refresh tokens in Node-Red applications</title>
      <link>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/261034#M938</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Generating the &lt;STRONG&gt;access token&lt;/STRONG&gt; for the very first time is a pain in the neck. All the more since the &lt;FONT color="#0000FF"&gt;&lt;EM&gt;authorization&lt;/EM&gt; &lt;EM&gt;code&lt;/EM&gt;&lt;/FONT&gt; parameter which has to be created and used to get the authorization token, has a very short 20 seconds time to live (TTL). So, you’d better hurry up and be nimble with ctrl-c and ctrl-v actions when using (semi-)manual solutions with Node-Red snippets, bash or Postman.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Once you’ve generated the access token, refreshing the access token by means of the refresh token every 59 minutes or so, is a snap. However, after 180 days the TTL of the refresh token has expired and you have to go through the cumbersome first-time generation process for the tokens again.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I felt kind of fed up with this – so I played around a bit and came to the solution described here. Please bear with me if my explanations seem a bit trivial or lengthy – I am an amateur not a professional. It took me quite a while to wrap my brain about this, so I’d like to walk you through my train of thought.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I guess there are other solutions around e.g. this one using php: &lt;A href="https://www.viessmann-community.com/t5/Getting-started-programming-with/To-help-get-started/td-p/181347" target="_blank" rel="noopener"&gt;https://www.viessmann-community.com/t5/Getting-started-programming-with/To-help-get-started/td-p/181347&lt;/A&gt;. However, I wanted to stay within Node-Red’s environment.&lt;/SPAN&gt;&lt;/P&gt;&lt;H1&gt;&amp;nbsp;&lt;/H1&gt;&lt;H1&gt;&lt;SPAN&gt;Walk Through&lt;/SPAN&gt;&lt;/H1&gt;&lt;P&gt;&lt;SPAN&gt;Node-Red has webserver capability by means of two http nodes: &lt;EM&gt;http in&lt;/EM&gt; and &lt;EM&gt;http response&lt;/EM&gt;. They exist under the local address of &lt;A href="http://localhost:1880" target="_blank" rel="noopener"&gt;http://localhost:1880&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;H2&gt;&amp;nbsp;&lt;/H2&gt;&lt;H2&gt;&lt;SPAN&gt;Step 1 – Authorization Request&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN&gt;To create the first call, you’ll need the following parameters:&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;&lt;H3&gt;&lt;SPAN&gt;client_id and redirect_uri&lt;/SPAN&gt;&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;Both are set by means of the Developer Dashboard at: &lt;A href="https://app.developer.viessmann.com/" target="_blank" rel="noopener"&gt;https://app.developer.viessmann.com/&lt;/A&gt;.&lt;BR /&gt;I’m assuming that you have already created an account.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="CaCicala_0-1664025783017.png" style="width: 400px;"&gt;&lt;img src="https://community.viessmann.de/t5/image/serverpage/image-id/12279i3A855322BB215457/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CaCicala_0-1664025783017.png" alt="CaCicala_0-1664025783017.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The &lt;STRONG&gt;client_id&lt;/STRONG&gt; is static, and does not change when you change the redirect_uri setting. It will be created during the first client setting but can be deleted and re-created as you like.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the generic example the &lt;STRONG&gt;redirect_uri&lt;/STRONG&gt; &lt;A href="http://localhost:4200" target="_blank" rel="noopener"&gt;http://localhost:4200&lt;/A&gt; is used. This works fine as long as you use a browser to generate the authorization code which can be copied from the URL field of the browser’s error message.&lt;BR /&gt;For our purposes however, we need to change this to &lt;A href="http://localhost:1880/authcode" target="_blank" rel="noopener"&gt;http://localhost:1880/authcode&lt;/A&gt;. The path &lt;EM&gt;authcode&lt;/EM&gt; can be anything but must be the same as the one used in the URL field of the &lt;EM&gt;http in&lt;/EM&gt; node we’re going to use further down.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Don’t forget to turn off the Google CAPTCHA setting.&lt;/SPAN&gt;&lt;/P&gt;&lt;H2&gt;&amp;nbsp;&lt;/H2&gt;&lt;H2&gt;&lt;SPAN&gt;Fixed parameters&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN&gt;Scope is set to &lt;/SPAN&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;scope = "IoT User"&lt;/EM&gt;&lt;/FONT&gt;&lt;SPAN&gt; this is important otherwise you won’t be able to do much.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Response Type is set to &lt;/SPAN&gt;&lt;SPAN&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;response_type = "code"&lt;/EM&gt;&lt;/FONT&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Code Challenge is set to&lt;BR /&gt;&lt;/SPAN&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;code_challenge=2e21faa1-db2c-4d0b-a10f-575fd372bc8c-575fd372bc8c&lt;/EM&gt;&lt;/FONT&gt;&lt;SPAN&gt; which is identical to the one used in the “&lt;A href="https://documentation.viessmann.com/static/getting-started" target="_blank" rel="noopener"&gt;Getting Started&lt;/A&gt;” chapter of Viessmann’s documentation. In my opinion you can continue to use that and forget about hashing and encoding as required by the oAuth method. I never was able to grasp the concept.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And, finally we &lt;STRONG&gt;must&lt;/STRONG&gt; add the parameter &lt;/SPAN&gt;&lt;SPAN&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;offline_acces&lt;/EM&gt;s&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN&gt; to also get the refresh token lateron.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The URL assembled to generate the authorization request looks like this (blanks are ecoded by &lt;/SPAN&gt;&lt;SPAN&gt;%20&lt;/SPAN&gt;&lt;SPAN&gt;) :&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;https://iam.viessmann.com/idp/v2/authorize?client_id=my_oauth_client_ID&amp;amp;redirect_uri=http://localhost:1880/authcode&amp;amp;response_type=code&amp;amp;code_challenge=2e21faa1-db2c-4d0b-a10f-575fd372bc8c-575fd372bc8c&amp;amp;scope=IoT%20User%20offline_access&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now we can drag an &lt;EM&gt;http request node&lt;/EM&gt; to the development area of Node-Red, additionally a Trigger node and a debug node&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CaCicala_1-1664025783018.png" style="width: 999px;"&gt;&lt;img src="https://community.viessmann.de/t5/image/serverpage/image-id/12281i69E7246D162592D1/image-size/large?v=v2&amp;amp;px=999" role="button" title="CaCicala_1-1664025783018.png" alt="CaCicala_1-1664025783018.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The request Node is configured as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Method is GET, URL is the one shown above, Payload is ignored, Basic Authentication is used and is set to your Viessman Login Username and Password, the rest stays as it is.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="4_config_request_node.png" style="width: 999px;"&gt;&lt;img src="https://community.viessmann.de/t5/image/serverpage/image-id/12289i05ADECC98874F13D/image-size/large?v=v2&amp;amp;px=999" role="button" title="4_config_request_node.png" alt="4_config_request_node.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To receive this request, we need to set up a minimal webserver by using the &lt;EM&gt;http in&lt;/EM&gt; and &lt;EM&gt;http response&lt;/EM&gt; nodes. This looks like so:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="CaCicala_3-1664025783028.png" style="width: 999px;"&gt;&lt;img src="https://community.viessmann.de/t5/image/serverpage/image-id/12283i4EF9110B185A0081/image-size/large?v=v2&amp;amp;px=999" role="button" title="CaCicala_3-1664025783028.png" alt="CaCicala_3-1664025783028.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The &lt;EM&gt;http in&lt;/EM&gt; node is configured like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="CaCicala_4-1664025783031.png" style="width: 400px;"&gt;&lt;img src="https://community.viessmann.de/t5/image/serverpage/image-id/12282i69DC7AA467CFCEA0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CaCicala_4-1664025783031.png" alt="CaCicala_4-1664025783031.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The URL field has to correspond to the path used in the redirect URI – without server name and port number.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The response node is set to status code 200&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please note that the request part and the response part are &lt;STRONG&gt;not&lt;/STRONG&gt; connected by a wire. This is where Internet magic happens.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If all goes well, debug node at the receiving end should show the authorization code after you hit the trigger at the request side. The authorization code can be accessed by using &lt;/SPAN&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;msg.payload.code &lt;/EM&gt;&lt;/FONT&gt;&lt;SPAN&gt;&lt;FONT color="#0000FF"&gt;-&lt;/FONT&gt; we will need it in the following steps.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You will find the complete generic JSON code at the end of this article.&lt;/SPAN&gt;&lt;/P&gt;&lt;H2&gt;&amp;nbsp;&lt;/H2&gt;&lt;H2&gt;&lt;SPAN&gt;Step 2 – Authorization Code Exchange – initial generation of access and refresh tokens&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN&gt;Having created the authorization code represented by msg.payload.code, we can now continue along the Authentication chapter of the Viessmann doc pages. In Node-Red this looks like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CaCicala_5-1664025783050.png" style="width: 999px;"&gt;&lt;img src="https://community.viessmann.de/t5/image/serverpage/image-id/12284i99536184245F88D8/image-size/large?v=v2&amp;amp;px=999" role="button" title="CaCicala_5-1664025783050.png" alt="CaCicala_5-1664025783050.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The top left part we have already covered above.&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;&lt;H3&gt;&lt;SPAN&gt;The function node &lt;STRONG&gt;set payload &amp;amp; headers&lt;/STRONG&gt; is configured like this:&lt;/SPAN&gt;&lt;/H3&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;msg.payload = `grant_type=authorization_code&amp;amp;client_id=my_oauth_client_ID&amp;amp;redirect_uri=http://localhost:1880/authcode&amp;amp;code_verifier=2e21faa1-db2c-4d0b-a10f-575fd372bc8c-575fd372bc8c&amp;amp;code=${msg.payload.code}`;
msg.headers = {};
msg.headers['Content-Type'] = 'application/x-www-form-urlencoded';
return msg;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Watch out, the text after msg.payload is written as one single line only. Also observe the backtics which are necessary to concatenate the fixed part of the payload with the variable &lt;/SPAN&gt;&lt;EM&gt;“msg.payload.code”&lt;/EM&gt;&lt;SPAN&gt;. All in all, the JavaScript should consist of 4 lines. You will find the complete JSON (a pdf file) at the end of this article&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;&lt;H3&gt;&lt;SPAN&gt;The html request node &lt;STRONG&gt;1st time token request&lt;/STRONG&gt; looks like this:&lt;/SPAN&gt;&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="CaCicala_6-1664025783057.png" style="width: 400px;"&gt;&lt;img src="https://community.viessmann.de/t5/image/serverpage/image-id/12285i72BF98AA3648C5CE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CaCicala_6-1664025783057.png" alt="CaCicala_6-1664025783057.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Observe the setting: Return a parsed JSON object.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If all goes well, the JSON object contains both tokens which can be accessed by msg.payload.access_token and msg.payload.refresh_token.&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;&lt;H3&gt;&lt;SPAN&gt;Setting flow variables&lt;/SPAN&gt;&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;In my implementation, I have everything concerning the ViCare API in one flow tab. Hence, I’m using &lt;STRONG&gt;flow&lt;/STRONG&gt; variables. In case you have distributed the flows on several tabs, you should use global variables instead of flow variables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now it’s time to push our response into variables. I use a change node for that.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="CaCicala_7-1664025783068.png" style="width: 400px;"&gt;&lt;img src="https://community.viessmann.de/t5/image/serverpage/image-id/12286iD1491898182F2F6F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CaCicala_7-1664025783068.png" alt="CaCicala_7-1664025783068.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;&lt;H3&gt;&lt;SPAN&gt;Retrieving Static values (once)&lt;/SPAN&gt;&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;In addition, you will need the static values for&lt;FONT color="#0000FF"&gt; &lt;EM&gt;InstallationID&lt;/EM&gt;, &lt;EM&gt;gatewaySerial&lt;/EM&gt;&lt;/FONT&gt; and &lt;FONT color="#0000FF"&gt;&lt;EM&gt;deviceID.&lt;/EM&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;You can either generate them once and hard-code them into your flow or re-request them every time, you’re running the initialization logic. In my example, I’m generating them during initialization. It’s a sequence of 3 requests, so we shouldn’t request these values too often – besides it’s unnecessary, they never change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CaCicala_8-1664025783078.png" style="width: 999px;"&gt;&lt;img src="https://community.viessmann.de/t5/image/serverpage/image-id/12287iB6062B1DDDEF327F/image-size/large?v=v2&amp;amp;px=999" role="button" title="CaCicala_8-1664025783078.png" alt="CaCicala_8-1664025783078.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Refer to section &lt;A href="https://documentation.viessmann.com/static/iot/overview" target="_blank" rel="noopener"&gt;IOT - Overview&lt;/A&gt; of the Viessman documentation for their creation or simply go through the JSON (pdf File) provided at the end of this article.&lt;/P&gt;&lt;H1&gt;&amp;nbsp;&lt;/H1&gt;&lt;H1&gt;&lt;EM&gt;Notes&lt;/EM&gt;&lt;/H1&gt;&lt;H2&gt;&amp;nbsp;&lt;/H2&gt;&lt;H2&gt;&lt;EM&gt;About refreshing the Access Token&lt;/EM&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN&gt;Please note that the automatic Access Token refresh should occur every 59 minutes or so, just in time before the token expires. You could trigger the initialization routine described above. It would generate a new access token from scratch at regular intervals. However, this would eat into your requests allowance and also create extra load on Viessman’s servers.&lt;BR /&gt;I recommend to use a specialized refresh flow on the same tab that performs the refresh by using the refresh token. I have written about this in my article &lt;A href="https://www.viessmann-community.com/t5/The-Viessmann-API/Using-Node-Red-to-visualize-ViCare-data/m-p/195606#M364" target="_blank" rel="noopener"&gt;“Using Node-Red to visualize ViCare data”&lt;/A&gt;. The according JSON Routine is provided there as well.&lt;/SPAN&gt;&lt;/P&gt;&lt;H2&gt;&amp;nbsp;&lt;/H2&gt;&lt;H2&gt;&lt;EM&gt;About Triggering&lt;/EM&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN&gt;How should you trigger this initialization process?&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;&lt;H3&gt;&lt;SPAN&gt;Manually&lt;/SPAN&gt;&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;If your availability requirements are relaxed, you might as well trigger the initialization manually every time your application fails because of an expired refresh token i.e. every 180 days. &lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;&lt;H3&gt;&lt;SPAN&gt;Automatically&lt;/SPAN&gt;&lt;/H3&gt;&lt;P&gt;&lt;SPAN&gt;As soon as the refresh token is no longer valid, the Viessmann server’s JSON response will contain a &lt;EM&gt;&lt;FONT color="#0000FF"&gt;payload.&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;error&lt;/SPAN&gt; = &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;"EXPIRED TOKEN"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/EM&gt; message. You can use this with a switch node to branch to the initialization routine in the rare event the refresh token is expired.&lt;/SPAN&gt;&lt;/P&gt;&lt;H2&gt;&amp;nbsp;&lt;/H2&gt;&lt;H2&gt;&lt;SPAN&gt;Using the API&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN&gt;Please refer to my article &lt;A href="https://www.viessmann-community.com/t5/The-Viessmann-API/Using-Node-Red-to-visualize-ViCare-data/m-p/195606#M364" target="_blank" rel="noopener"&gt;“Using Node-Red to visualize ViCare data”&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope that you find this useful. Any comment is highly appreciated. The code can be found in the answer post below or at my website.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Christoph Krzikalla&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CaCicala_9-1664025783092.png" style="width: 999px;"&gt;&lt;img src="https://community.viessmann.de/t5/image/serverpage/image-id/12288i16597C819CF54FAA/image-size/large?v=v2&amp;amp;px=999" role="button" title="CaCicala_9-1664025783092.png" alt="CaCicala_9-1664025783092.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 08:22:35 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/261034#M938</guid>
      <dc:creator>CaCicala</dc:creator>
      <dc:date>2023-02-09T08:22:35Z</dc:date>
    </item>
    <item>
      <title>Betreff: How to avoid sudden death after 180 days – automatic initialization and refresh of the access and refresh tokens in Node-Red applications</title>
      <link>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/265724#M980</link>
      <description>&lt;P&gt;Irgendwie wäre es schön, wenn es für derlei Tutorials einen eigenen Forenbereich gäbe. Ferner würde ich mir wünschen, als Autor nachträglich och Änderungen vornehmen zu können.&amp;nbsp;&lt;BR /&gt;Oder wäre es besser, nur einen kurzen Einleitungstext zu schreiben und das Tutorial dann als pdf anzuhängen?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 14:35:16 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/265724#M980</guid>
      <dc:creator>CaCicala</dc:creator>
      <dc:date>2022-10-06T14:35:16Z</dc:date>
    </item>
    <item>
      <title>Betreff: How to avoid sudden death after 180 days – automatic initialization and refresh of the access and refresh tokens in Node-Red applications</title>
      <link>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/266233#M982</link>
      <description>&lt;P&gt;Hey.&lt;/P&gt;&lt;P&gt;Great help for my first time start with NodeRed.&lt;/P&gt;&lt;P&gt;But when I copy/paste the initialize token text and import it in NodeRed I get a error message&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;SyntaxError: Unexpected string in JSON at position 4745&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;tot": "msg"↵&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;reg": false&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Any idea where my mistake is?&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 07 Oct 2022 19:07:23 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/266233#M982</guid>
      <dc:creator>Castorp</dc:creator>
      <dc:date>2022-10-07T19:07:23Z</dc:date>
    </item>
    <item>
      <title>Betreff: How to avoid sudden death after 180 days – automatic initialization and refresh of the access and refresh tokens in Node-Red applications</title>
      <link>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/266264#M983</link>
      <description>&lt;P&gt;oops!!&lt;/P&gt;&lt;P&gt;Da hat mir der pdf Konverter einen Streich gesielt und zu lange Zeilen mit einem Zeilenumbruchzeichen "verschönert".&lt;/P&gt;&lt;P&gt;Abhilfe fürs Erste: Text mit Ctrl-C und Ctrl-V (bzw. Strg-...) kopieren und in einen Editor pasten. Dann bei den im Import angegebenen Zeilen&lt;/P&gt;&lt;P&gt;hier zum Beispiel Zeile 60 die Zeilen zusammenfügen:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CaCicala_0-1665174244992.png" style="width: 400px;"&gt;&lt;img src="https://community.viessmann.de/t5/image/serverpage/image-id/12700i45CD35BAC1FBB7DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CaCicala_0-1665174244992.png" alt="CaCicala_0-1665174244992.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Tut mir ausgesprichen leid. Ich versuche das in der kommenden Woche irgendwie zu beheben. Saublöd. dass man keine JSON oder TXT Dateien im Forum Hochladen kann...&lt;/P&gt;&lt;P&gt;VG&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 20:25:49 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/266264#M983</guid>
      <dc:creator>CaCicala</dc:creator>
      <dc:date>2022-10-07T20:25:49Z</dc:date>
    </item>
    <item>
      <title>Betreff: How to avoid sudden death after 180 days – automatic initialization and refresh of the access and refresh tokens in Node-Red applications</title>
      <link>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/266271#M984</link>
      <description>&lt;P&gt;Ich habe hier nochmal das korrekte JSON per cut&amp;amp;paste eingefügt. Per pdf scheint das nicht zu funktionieren.&lt;/P&gt;&lt;P&gt;Sorry nochmal für die Verwirrung.&lt;/P&gt;&lt;P&gt;VG&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;P&gt;+++++++++++++++++++++++++++++++++++++++++++++++&lt;/P&gt;&lt;P&gt;[&lt;BR /&gt;{&lt;BR /&gt;"id": "9d0e5593d53b55d0",&lt;BR /&gt;"type": "debug",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "complete msg object",&lt;BR /&gt;"active": true,&lt;BR /&gt;"tosidebar": true,&lt;BR /&gt;"console": false,&lt;BR /&gt;"tostatus": false,&lt;BR /&gt;"complete": "true",&lt;BR /&gt;"targetType": "full",&lt;BR /&gt;"statusVal": "",&lt;BR /&gt;"statusType": "auto",&lt;BR /&gt;"x": 1000,&lt;BR /&gt;"y": 340,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "d6e3257c9c2d54ad",&lt;BR /&gt;"type": "http request",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "1st time Token Request",&lt;BR /&gt;"method": "POST",&lt;BR /&gt;"ret": "obj",&lt;BR /&gt;"paytoqs": "ignore",&lt;BR /&gt;"url": "&lt;A href="https://iam.viessmann.com/idp/v2/token" target="_blank"&gt;https://iam.viessmann.com/idp/v2/token&lt;/A&gt;",&lt;BR /&gt;"tls": "",&lt;BR /&gt;"persist": false,&lt;BR /&gt;"proxy": "",&lt;BR /&gt;"insecureHTTPParser": false,&lt;BR /&gt;"authType": "",&lt;BR /&gt;"senderr": false,&lt;BR /&gt;"headers": [],&lt;BR /&gt;"x": 730,&lt;BR /&gt;"y": 460,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"9d0e5593d53b55d0",&lt;BR /&gt;"a15685d5a21c73f4",&lt;BR /&gt;"4cd4555c4b8a54e4",&lt;BR /&gt;"e3bde0eca33a67c8"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "46386b17e466c5b4",&lt;BR /&gt;"type": "function",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "set payload &amp;amp; headers",&lt;BR /&gt;"func": "msg.payload = `grant_type=authorization_code&amp;amp;client_id=YOURCLIENTID&amp;amp;redirect_uri=&lt;A href="http://localhost:1880/authcode&amp;amp;code_verifier=2e21faa1-db2c-4d0b-a10f-575fd372bc8c-575fd372bc8c&amp;amp;code=${msg.payload.code" target="_blank"&gt;http://localhost:1880/authcode&amp;amp;code_verifier=2e21faa1-db2c-4d0b-a10f-575fd372bc8c-575fd372bc8c&amp;amp;code=${msg.payload.code&lt;/A&gt;}`;\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/x-www-form-urlencoded';\n\nreturn msg;",&lt;BR /&gt;"outputs": 1,&lt;BR /&gt;"noerr": 0,&lt;BR /&gt;"initialize": "",&lt;BR /&gt;"finalize": "",&lt;BR /&gt;"libs": [],&lt;BR /&gt;"x": 480,&lt;BR /&gt;"y": 460,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"d6e3257c9c2d54ad"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "d5abc46074c395a0",&lt;BR /&gt;"type": "inject",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "",&lt;BR /&gt;"props": [&lt;BR /&gt;{&lt;BR /&gt;"p": "payload"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"p": "topic",&lt;BR /&gt;"vt": "str"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"repeat": "",&lt;BR /&gt;"crontab": "",&lt;BR /&gt;"once": true,&lt;BR /&gt;"onceDelay": 0.1,&lt;BR /&gt;"topic": "",&lt;BR /&gt;"payload": "",&lt;BR /&gt;"payloadType": "date",&lt;BR /&gt;"x": 290,&lt;BR /&gt;"y": 240,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"c765f5d53247981e"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "595c3f168551465e",&lt;BR /&gt;"type": "debug",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Request Result",&lt;BR /&gt;"active": true,&lt;BR /&gt;"tosidebar": true,&lt;BR /&gt;"console": false,&lt;BR /&gt;"tostatus": false,&lt;BR /&gt;"complete": "payload",&lt;BR /&gt;"targetType": "msg",&lt;BR /&gt;"statusVal": "",&lt;BR /&gt;"statusType": "auto",&lt;BR /&gt;"x": 620,&lt;BR /&gt;"y": 240,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "904e0e39a0436cf7",&lt;BR /&gt;"type": "http in",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "",&lt;BR /&gt;"url": "/authcode",&lt;BR /&gt;"method": "get",&lt;BR /&gt;"upload": false,&lt;BR /&gt;"swaggerDoc": "",&lt;BR /&gt;"x": 240,&lt;BR /&gt;"y": 360,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"beb9836fcb2f735c",&lt;BR /&gt;"1282ee44e06b324d",&lt;BR /&gt;"46386b17e466c5b4"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "beb9836fcb2f735c",&lt;BR /&gt;"type": "debug",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "msg.payload.code",&lt;BR /&gt;"active": true,&lt;BR /&gt;"tosidebar": true,&lt;BR /&gt;"console": false,&lt;BR /&gt;"tostatus": false,&lt;BR /&gt;"complete": "payload.code",&lt;BR /&gt;"targetType": "msg",&lt;BR /&gt;"statusVal": "",&lt;BR /&gt;"statusType": "auto",&lt;BR /&gt;"x": 470,&lt;BR /&gt;"y": 320,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "1282ee44e06b324d",&lt;BR /&gt;"type": "http response",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Reponse",&lt;BR /&gt;"statusCode": "200",&lt;BR /&gt;"headers": {},&lt;BR /&gt;"x": 440,&lt;BR /&gt;"y": 360,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "13da70accda71262",&lt;BR /&gt;"type": "comment",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Generate authorization code",&lt;BR /&gt;"info": "",&lt;BR /&gt;"x": 320,&lt;BR /&gt;"y": 200,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "c765f5d53247981e",&lt;BR /&gt;"type": "http request",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "",&lt;BR /&gt;"method": "GET",&lt;BR /&gt;"ret": "txt",&lt;BR /&gt;"paytoqs": "ignore",&lt;BR /&gt;"url": "&lt;A href="https://iam.viessmann.com/idp/v2/authorize?client_id=a602c3ccb073b72740420f03ad1b21f3&amp;amp;redirect_uri=http://localhost:1880/authcode&amp;amp;response_type=code&amp;amp;code_challenge=2e21faa1-db2c-4d0b-a10f-575fd372bc8c-575fd372bc8c&amp;amp;scope=IoT%20User%20offline_access" target="_blank"&gt;https://iam.viessmann.com/idp/v2/authorize?client_id=a602c3ccb073b72740420f03ad1b21f3&amp;amp;redirect_uri=http://localhost:1880/authcode&amp;amp;response_type=code&amp;amp;code_challenge=2e21faa1-db2c-4d0b-a10f-575fd372bc8c-575fd372bc8c&amp;amp;scope=IoT%20User%20offline_access&lt;/A&gt;",&lt;BR /&gt;"tls": "",&lt;BR /&gt;"persist": false,&lt;BR /&gt;"proxy": "",&lt;BR /&gt;"insecureHTTPParser": false,&lt;BR /&gt;"authType": "basic",&lt;BR /&gt;"senderr": false,&lt;BR /&gt;"headers": [],&lt;BR /&gt;"x": 450,&lt;BR /&gt;"y": 240,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"595c3f168551465e"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "296e1357a73c8e32",&lt;BR /&gt;"type": "comment",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Click here --&amp;gt;",&lt;BR /&gt;"info": "",&lt;BR /&gt;"x": 110,&lt;BR /&gt;"y": 240,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "751a30abd962d114",&lt;BR /&gt;"type": "comment",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "after expiry",&lt;BR /&gt;"info": "",&lt;BR /&gt;"x": 100,&lt;BR /&gt;"y": 200,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "a15685d5a21c73f4",&lt;BR /&gt;"type": "debug",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "access_token",&lt;BR /&gt;"active": false,&lt;BR /&gt;"tosidebar": true,&lt;BR /&gt;"console": false,&lt;BR /&gt;"tostatus": false,&lt;BR /&gt;"complete": "payload",&lt;BR /&gt;"targetType": "msg",&lt;BR /&gt;"statusVal": "",&lt;BR /&gt;"statusType": "auto",&lt;BR /&gt;"x": 980,&lt;BR /&gt;"y": 420,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "e3bde0eca33a67c8",&lt;BR /&gt;"type": "debug",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "refresh_token",&lt;BR /&gt;"active": false,&lt;BR /&gt;"tosidebar": true,&lt;BR /&gt;"console": false,&lt;BR /&gt;"tostatus": false,&lt;BR /&gt;"complete": "payload",&lt;BR /&gt;"targetType": "msg",&lt;BR /&gt;"statusVal": "",&lt;BR /&gt;"statusType": "auto",&lt;BR /&gt;"x": 980,&lt;BR /&gt;"y": 380,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "4cd4555c4b8a54e4",&lt;BR /&gt;"type": "change",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "set token flow variables",&lt;BR /&gt;"rules": [&lt;BR /&gt;{&lt;BR /&gt;"t": "set",&lt;BR /&gt;"p": "accessToken",&lt;BR /&gt;"pt": "flow",&lt;BR /&gt;"to": "payload.access_token",&lt;BR /&gt;"tot": "msg"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"t": "set",&lt;BR /&gt;"p": "refreshToken",&lt;BR /&gt;"pt": "flow",&lt;BR /&gt;"to": "payload.refresh_token",&lt;BR /&gt;"tot": "msg"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"action": "",&lt;BR /&gt;"property": "",&lt;BR /&gt;"from": "",&lt;BR /&gt;"to": "",&lt;BR /&gt;"reg": false,&lt;BR /&gt;"x": 1010,&lt;BR /&gt;"y": 460,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"0a5b06420e87d77f"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "3d828c3c867062b0",&lt;BR /&gt;"type": "http request",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Installation ID",&lt;BR /&gt;"method": "GET",&lt;BR /&gt;"ret": "obj",&lt;BR /&gt;"paytoqs": "ignore",&lt;BR /&gt;"url": "&lt;A href="https://api.viessmann.com/iot/v1/equipment/installations" target="_blank"&gt;https://api.viessmann.com/iot/v1/equipment/installations&lt;/A&gt;",&lt;BR /&gt;"tls": "",&lt;BR /&gt;"persist": false,&lt;BR /&gt;"proxy": "",&lt;BR /&gt;"insecureHTTPParser": false,&lt;BR /&gt;"authType": "",&lt;BR /&gt;"senderr": false,&lt;BR /&gt;"headers": [],&lt;BR /&gt;"x": 680,&lt;BR /&gt;"y": 600,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"f32181561f6a81ab"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "0a5b06420e87d77f",&lt;BR /&gt;"type": "function",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Auth Header",&lt;BR /&gt;"func": "var atoken = flow.get('accessToken')\nmsg.headers = {\n Authorization: \"Bearer \"+ atoken\n}\nreturn msg;\n\n",&lt;BR /&gt;"outputs": 1,&lt;BR /&gt;"noerr": 0,&lt;BR /&gt;"initialize": "",&lt;BR /&gt;"finalize": "",&lt;BR /&gt;"libs": [],&lt;BR /&gt;"x": 450,&lt;BR /&gt;"y": 600,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"3d828c3c867062b0"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "d189c65f2d221d39",&lt;BR /&gt;"type": "http request",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Gateway Serial",&lt;BR /&gt;"method": "GET",&lt;BR /&gt;"ret": "obj",&lt;BR /&gt;"paytoqs": "ignore",&lt;BR /&gt;"url": "&lt;A href="https://api.viessmann.com/iot/v1/equipment/gateways" target="_blank"&gt;https://api.viessmann.com/iot/v1/equipment/gateways&lt;/A&gt;",&lt;BR /&gt;"tls": "",&lt;BR /&gt;"persist": false,&lt;BR /&gt;"proxy": "",&lt;BR /&gt;"insecureHTTPParser": false,&lt;BR /&gt;"authType": "",&lt;BR /&gt;"senderr": false,&lt;BR /&gt;"headers": [],&lt;BR /&gt;"x": 680,&lt;BR /&gt;"y": 640,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"a92443f4485556c4"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "f32181561f6a81ab",&lt;BR /&gt;"type": "change",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "set flow.installationID",&lt;BR /&gt;"rules": [&lt;BR /&gt;{&lt;BR /&gt;"t": "set",&lt;BR /&gt;"p": "installationID",&lt;BR /&gt;"pt": "flow",&lt;BR /&gt;"to": "payload.data[0].id",&lt;BR /&gt;"tot": "msg"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"action": "",&lt;BR /&gt;"property": "",&lt;BR /&gt;"from": "",&lt;BR /&gt;"to": "",&lt;BR /&gt;"reg": false,&lt;BR /&gt;"x": 880,&lt;BR /&gt;"y": 600,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"dadfb8ae29d2643b"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "a92443f4485556c4",&lt;BR /&gt;"type": "change",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "set flow.gatewaySerial",&lt;BR /&gt;"rules": [&lt;BR /&gt;{&lt;BR /&gt;"t": "set",&lt;BR /&gt;"p": "gatewaySerial",&lt;BR /&gt;"pt": "flow",&lt;BR /&gt;"to": "payload.data[0].serial",&lt;BR /&gt;"tot": "msg"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"action": "",&lt;BR /&gt;"property": "",&lt;BR /&gt;"from": "",&lt;BR /&gt;"to": "",&lt;BR /&gt;"reg": false,&lt;BR /&gt;"x": 880,&lt;BR /&gt;"y": 640,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"5cfecbbe8f899905"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "dadfb8ae29d2643b",&lt;BR /&gt;"type": "function",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "Auth Header",&lt;BR /&gt;"func": "var atoken = flow.get('accessToken')\nmsg.headers = {\n Authorization: \"Bearer \"+ atoken\n}\nreturn msg;\n\n",&lt;BR /&gt;"outputs": 1,&lt;BR /&gt;"noerr": 0,&lt;BR /&gt;"initialize": "",&lt;BR /&gt;"finalize": "",&lt;BR /&gt;"libs": [],&lt;BR /&gt;"x": 450,&lt;BR /&gt;"y": 640,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"d189c65f2d221d39"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "f52e123cdd02a6bc",&lt;BR /&gt;"type": "http request",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "DeviceID",&lt;BR /&gt;"method": "GET",&lt;BR /&gt;"ret": "obj",&lt;BR /&gt;"paytoqs": "ignore",&lt;BR /&gt;"url": "&lt;A href="https://api.viessmann.com/iot/v1/equipment/installations/{{iid}}/gateways/{{gws}}/devices/" target="_blank"&gt;https://api.viessmann.com/iot/v1/equipment/installations/{{iid}}/gateways/{{gws}}/devices/&lt;/A&gt; ",&lt;BR /&gt;"tls": "",&lt;BR /&gt;"persist": false,&lt;BR /&gt;"proxy": "",&lt;BR /&gt;"insecureHTTPParser": false,&lt;BR /&gt;"authType": "",&lt;BR /&gt;"senderr": false,&lt;BR /&gt;"headers": [],&lt;BR /&gt;"x": 660,&lt;BR /&gt;"y": 680,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"e553113d728f21a8"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "e553113d728f21a8",&lt;BR /&gt;"type": "change",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "",&lt;BR /&gt;"rules": [&lt;BR /&gt;{&lt;BR /&gt;"t": "set",&lt;BR /&gt;"p": "deviceID",&lt;BR /&gt;"pt": "flow",&lt;BR /&gt;"to": "payload.data[0].id",&lt;BR /&gt;"tot": "msg"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"action": "",&lt;BR /&gt;"property": "",&lt;BR /&gt;"from": "",&lt;BR /&gt;"to": "",&lt;BR /&gt;"reg": false,&lt;BR /&gt;"x": 870,&lt;BR /&gt;"y": 680,&lt;BR /&gt;"wires": [&lt;BR /&gt;[]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "5cfecbbe8f899905",&lt;BR /&gt;"type": "function",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "extended auth header",&lt;BR /&gt;"func": "//var o = parseFloat(flow.get('2vo1'));\n//var atoken = msg.token\nvar atoken = flow.get('accessToken')\nmsg.headers = {\n Authorization: \"Bearer \"+ atoken\n}\nmsg.iid = flow.get('installationID');\nmsg.gws = flow.get('gatewaySerial');\nreturn msg;\n\n",&lt;BR /&gt;"outputs": 1,&lt;BR /&gt;"noerr": 0,&lt;BR /&gt;"initialize": "",&lt;BR /&gt;"finalize": "",&lt;BR /&gt;"libs": [],&lt;BR /&gt;"x": 480,&lt;BR /&gt;"y": 680,&lt;BR /&gt;"wires": [&lt;BR /&gt;[&lt;BR /&gt;"f52e123cdd02a6bc"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "27904bd00d57b5f8",&lt;BR /&gt;"type": "comment",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "get tokens 1st time",&lt;BR /&gt;"info": "",&lt;BR /&gt;"x": 290,&lt;BR /&gt;"y": 420,&lt;BR /&gt;"wires": []&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"id": "5ddbfc6f31907258",&lt;BR /&gt;"type": "comment",&lt;BR /&gt;"z": "31c57f8640528976",&lt;BR /&gt;"name": "get/set invariable parameters",&lt;BR /&gt;"info": "",&lt;BR /&gt;"x": 320,&lt;BR /&gt;"y": 540,&lt;BR /&gt;"wires": []&lt;BR /&gt;}&lt;BR /&gt;]&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 20:41:57 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/266271#M984</guid>
      <dc:creator>CaCicala</dc:creator>
      <dc:date>2022-10-07T20:41:57Z</dc:date>
    </item>
    <item>
      <title>Betreff: How to avoid sudden death after 180 days – automatic initialization and refresh of the access and refresh tokens in Node-Red applications</title>
      <link>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/266293#M985</link>
      <description>&lt;P&gt;Großartig! Import hat auf Anhieb funktioniert.&lt;/P&gt;&lt;P&gt;Vielen Dank!!!&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2022 06:56:31 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/266293#M985</guid>
      <dc:creator>Castorp</dc:creator>
      <dc:date>2022-10-08T06:56:31Z</dc:date>
    </item>
    <item>
      <title>Betreff: How to avoid sudden death after 180 days – automatic initialization and refresh of the access and refresh tokens in Node-Red applications</title>
      <link>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/295281#M1272</link>
      <description>&lt;P&gt;Alter Schwede.&lt;BR /&gt;Ich habe mich jetzt echt ne weile mit der API gequält.&lt;/P&gt;&lt;P&gt;Das war der Beitrag, den ich gebraucht habe.&lt;/P&gt;&lt;P&gt;Danke Chris&lt;/P&gt;</description>
      <pubDate>Sat, 24 Dec 2022 15:20:11 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/295281#M1272</guid>
      <dc:creator>Hectopascal</dc:creator>
      <dc:date>2022-12-24T15:20:11Z</dc:date>
    </item>
    <item>
      <title>Betreff: How to avoid sudden death after 180 days – automatic initialization and refresh of the access and refresh tokens in Node-Red applications</title>
      <link>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/303526#M1312</link>
      <description>&lt;P&gt;Mittlerweile habe ich einige meiner Tutorials auf Deutsch umgestellt, aktualisiert und auf meinem kleinen Tech-Blog veröffentlicht. Ihr findet das auf &lt;A href="https://rustimation.eu" target="_blank"&gt;https://rustimation.eu&lt;/A&gt; - wird je nach Erkenntnisfortschritt erweitert und ergänzt.&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 15:56:25 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/The-Viessmann-API/How-to-avoid-sudden-death-after-180-days-automatic/m-p/303526#M1312</guid>
      <dc:creator>CaCicala</dc:creator>
      <dc:date>2023-01-19T15:56:25Z</dc:date>
    </item>
  </channel>
</rss>

