Hi all I'm getting data from an api with a bearer token.
when I enter bearer token to http node I can connect to server and get my api data
when ever token expires I copy the new one and paste it to http node and deploy ://
I'm trying to come up with an easy solution for this situation.
So I'm listening http://192.168.1.45:1880/google to get new token messages sent from my phone by siri shortcuts (just a post request to http://192.168.1.46:1880/google?token=blablablablablablablablabla)
but I cannot use this token as header of my post request I tried alot of combinations without success
here is my flow
[{"id":"8df21d5.cdb3ae","type":"http in","z":"f5f01ef7.09a1a","name":"","url":"/google","method":"get","upload":false,"swaggerDoc":"","x":250,"y":740,"wires":[["54c1e70d.ab3e18","59335758.c6cb9"]]},{"id":"54c1e70d.ab3e18","type":"template","z":"f5f01ef7.09a1a","name":"page","field":"payload","fieldType":"msg","format":"html","syntax":"plain","template":"<html>\n <head></head>\n <body>\n <h1>THANKS</h1>\n </body>\n</html>","x":270,"y":840,"wires":[["266c286f.d993d8"]]},{"id":"266c286f.d993d8","type":"http response","z":"f5f01ef7.09a1a","name":"","x":410,"y":840,"wires":[]},{"id":"a2cbddc7.1cd338","type":"debug","z":"f5f01ef7.09a1a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":740,"wires":[]},{"id":"59335758.c6cb9","type":"json","z":"f5f01ef7.09a1a","name":"","property":"token","action":"obj","pretty":false,"x":430,"y":740,"wires":[["ec79908c.6fb2"]]},{"id":"ec79908c.6fb2","type":"change","z":"f5f01ef7.09a1a","name":"","rules":[{"t":"set","p":"globtoken","pt":"flow","to":"payload.token","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":740,"wires":[["a2cbddc7.1cd338"]]},{"id":"435adb93.9ee1dc","type":"http request","z":"f5f01ef7.09a1a","name":"","method":"GET","ret":"txt","paytoqs":"body","url":"testest.com","tls":"","persist":false,"proxy":"","authType":"bearer","x":630,"y":940,"wires":[["a7d99da4.5cd938"]]},{"id":"8d5dcc1.db91ab","type":"inject","z":"f5f01ef7.09a1a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":940,"wires":[["1594a5cc.91a492"]]},{"id":"d0e2df30.a484f","type":"ui_text","z":"f5f01ef7.09a1a","group":"8f918d7.5af32f","order":4,"width":2,"height":2,"name":"","label":"","format":"{{msg.online}}","layout":"col-center","x":1150,"y":940,"wires":[]},{"id":"a7d99da4.5cd938","type":"json","z":"f5f01ef7.09a1a","name":"","property":"payload","action":"obj","pretty":false,"x":790,"y":940,"wires":[["2c25c5f6.75fd6a"]]},{"id":"2c25c5f6.75fd6a","type":"change","z":"f5f01ef7.09a1a","name":"","rules":[{"t":"set","p":"online","pt":"msg","to":"payload.totalsForAllResults[\"rt:activeUsers\"]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":940,"wires":[["d0e2df30.a484f"]]},{"id":"1594a5cc.91a492","type":"function","z":"f5f01ef7.09a1a","name":"","func":"var tokengelen = flow.get('globtoken');\nvar bearer = 'Bearer ' + tokengelen;\n\nmsg.headers = {\n 'Authorization': bearer, \n \"Content-Type\" : \"application/json\"\n};\n\nmsg.payload = {\n \n}\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":940,"wires":[["435adb93.9ee1dc"]]},{"id":"8f918d7.5af32f","type":"ui_group","name":"all","tab":"c1dcfb03.ffed9","order":5,"disp":false,"width":13,"collapse":false},{"id":"c1dcfb03.ffed9","type":"ui_tab","name":"dash","icon":"dashboard","order":1}]
and here is my failed function
var tokengelen = flow.get('globtoken');
var bearer = 'Bearer ' + tokengelen;
msg.headers = {
'Authorization': bearer,
"Content-Type" : "application/json"
};
msg.payload = {
}
return msg;
thanks alot