Skip to content

Instantly share code, notes, and snippets.

@Farmer-Eds-Shed
Last active October 1, 2022 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Farmer-Eds-Shed/022156e998f47d127de6301024df818e to your computer and use it in GitHub Desktop.
Save Farmer-Eds-Shed/022156e998f47d127de6301024df818e to your computer and use it in GitHub Desktop.
farmOS_NR_authorization_code&client_credentials
[
{
"id": "303133fd2c8b50b5",
"type": "http in",
"z": "a288bc4cb4e3037b",
"name": "",
"url": "/farmos/callback",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 160,
"y": 280,
"wires": [
[
"9dfb72998072297b",
"1bad39c1a61928d6"
]
]
},
{
"id": "9dfb72998072297b",
"type": "template",
"z": "a288bc4cb4e3037b",
"name": "page",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "<html>\n <head></head>\n <body>\n <h1>Login complete return to application</h1>\n </body>\n</html>",
"x": 110,
"y": 200,
"wires": [
[
"762561a57a42ac44"
]
]
},
{
"id": "762561a57a42ac44",
"type": "http response",
"z": "a288bc4cb4e3037b",
"name": "",
"statusCode": "",
"headers": {},
"x": 250,
"y": 200,
"wires": []
},
{
"id": "98d47502b6480135",
"type": "debug",
"z": "a288bc4cb4e3037b",
"name": "debug 2",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 980,
"y": 340,
"wires": []
},
{
"id": "3457d8031de8cd42",
"type": "function",
"z": "a288bc4cb4e3037b",
"name": "authorization_code",
"func": "msg.payload ={\n \"grant_type\": \"authorization_code\",\n \"client_id\": msg.client,\n \"code\": msg.payload.code,\n \"state\": msg.payload.state,\n \"redirect_uri\": msg.redirect,\n \"client_secret\": msg.secret,\n \"scope\": msg.scope\n }\n\nmsg.headers = {};\nmsg.headers['Accept'] = \"application/json\";\nmsg.headers['content-type'] = 'application/x-www-form-urlencoded';\n\nmsg.method = \"POST\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 610,
"y": 280,
"wires": [
[
"40a71fd2da425e1a"
]
]
},
{
"id": "1bad39c1a61928d6",
"type": "credentials",
"z": "a288bc4cb4e3037b",
"name": "",
"props": [
{
"value": "client",
"type": "msg"
},
{
"value": "redirect",
"type": "msg"
},
{
"value": "secret",
"type": "msg"
},
{
"value": "scope",
"type": "msg"
},
{
"value": "url",
"type": "msg"
}
],
"credentials": {},
"x": 410,
"y": 280,
"wires": [
[
"3457d8031de8cd42"
]
]
},
{
"id": "40a71fd2da425e1a",
"type": "http request",
"z": "a288bc4cb4e3037b",
"name": "",
"method": "use",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": true,
"authType": "",
"senderr": false,
"headers": [],
"x": 810,
"y": 340,
"wires": [
[
"98d47502b6480135"
]
]
},
{
"id": "4fad059381b91f7d",
"type": "function",
"z": "a288bc4cb4e3037b",
"name": "Client Credentials",
"func": "msg.payload = {\n \"grant_type\": \"client_credentials\",\n \"client_id\": msg.client,\n \"client_secret\": msg.secret,\n \"scope\": \"farm_manager\"\n}\n\nmsg.headers = {};\nmsg.headers['Accept'] = \"application/json\";\nmsg.headers['content-type'] = 'application/x-www-form-urlencoded';\n\nmsg.method = \"POST\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 610,
"y": 400,
"wires": [
[
"40a71fd2da425e1a"
]
]
},
{
"id": "98354da15a2ee135",
"type": "inject",
"z": "a288bc4cb4e3037b",
"name": "",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 250,
"y": 400,
"wires": [
[
"3036eb3293f98626"
]
]
},
{
"id": "3036eb3293f98626",
"type": "credentials",
"z": "a288bc4cb4e3037b",
"name": "",
"props": [
{
"value": "client",
"type": "msg"
},
{
"value": "secret",
"type": "msg"
},
{
"value": "url",
"type": "msg"
}
],
"x": 410,
"y": 400,
"wires": [
[
"4fad059381b91f7d"
]
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment