diff --git a/README.md b/README.md index c500527..9052fb0 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ The node provides two modes of operation: ![image](https://user-images.githubusercontent.com/3945941/229128108-2e104b94-cd88-4e8e-be60-a746cefbf867.png) ```json -[{"id":"d15d33a4fa9a8ad9","type":"tab","label":"node-red-contrib-oauth2","disabled":false,"info":"","env":[]},{"id":"7e1a2f9059f99060","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"REFRESH","style":{"label":true,"stroke":"#7f7f7f","color":"#000000","fill":"#bfdbef"},"nodes":["d1ba341040cea0c3","aa24d69faa1640cd","efd1a2a910ca1051","a8fca004e704e071","9e9332c792dbdc01","7f22873286146e83"],"x":76,"y":499,"w":1210,"h":208},{"id":"7f22873286146e83","type":"group","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"via HTTP REQUEST","style":{"label":true},"nodes":["64d9243f.b7be7c","31727a2c.05a026","4030c52c.c2c29c","3b67977c.a53c08"],"x":102,"y":599,"w":1158,"h":82},{"id":"54025cb0a19e0f14","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Client Credentials","style":{"label":true,"stroke":"#a4a4a4","color":"#ffffff","fill":"#3f93cf"},"nodes":["10de26226e66ea9e","147aae5c70a7eecb","1e2169485cd2be43","ca6a8cddea946ab2","c6d4eb5c867902eb","d7a2041ef2683870","3f5a09c4fc8e769f"],"x":74,"y":179,"w":1212,"h":142},{"id":"f37b3410d0e03c57","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Authorization Code","style":{"label":true,"fill":"#3f93cf","color":"#ffffff"},"nodes":["8bd177259bc473f4","ee86852f62926632","d340377991d2d9b9","9e4d3edfde1766b9"],"x":74,"y":59,"w":1212,"h":82},{"id":"a783ce686ac81a0c","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Password","style":{"label":true,"fill":"#3f93cf","color":"#ffffff"},"nodes":["5ff7fb2616706080","8eadc61e4e5b4ac2","d857d0bc3e90d394","95745c4253c151f0","dcbde702eae7191d","d6a9695a923ab18b","c5da03044bdca6f1"],"x":74,"y":339,"w":1212,"h":142},{"id":"368ef084fe6b53de","type":"group","z":"d15d33a4fa9a8ad9","name":"Grant Type","style":{"label":true,"fill":"#bfc7d7","color":"#0070c0"},"nodes":["7e1a2f9059f99060","54025cb0a19e0f14","f37b3410d0e03c57","a783ce686ac81a0c"],"x":48,"y":33,"w":1264,"h":700},{"id":"ee86852f62926632","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"Authorization Code","container":"oauth2Response","grant_type":"authorization_code","access_token_url":"http://localhost:8080/v1/oauth/tokens","authorization_endpoint":"http://localhost:8080/web/authorize","redirect_uri":"/oauth2/redirect_uri","open_authentication":"c9cf92ea-6f1d-44b6-86ed-6de1279f45d8","username":"","password":"","client_id":"test_client_1","client_secret":"test_secret","scope":"read_write","client_credentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":450,"y":100,"wires":[["8bd177259bc473f4"]]},{"id":"9e4d3edfde1766b9","type":"inject","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":100,"wires":[["ee86852f62926632"]]},{"id":"d7a2041ef2683870","type":"debug","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"DBG 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":220,"wires":[]},{"id":"c6d4eb5c867902eb","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"Client Credentials","container":"oauth2Response","grant_type":"client_credentials","access_token_url":"http://localhost:8080/v1/oauth/tokens","authorization_endpoint":"http://localhost:8080/web/authorize","redirect_uri":"/oauth2/redirect_uri","open_authentication":"41595d3b-a2b5-41aa-84e7-02d2c7b54304","username":"","password":"","client_id":"test_client_1","client_secret":"test_secret","scope":"read_write","client_credentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":450,"y":220,"wires":[["1e2169485cd2be43"]]},{"id":"3f5a09c4fc8e769f","type":"inject","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":220,"wires":[["c6d4eb5c867902eb"]]},{"id":"d1ba341040cea0c3","type":"inject","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"Refresh Token","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3300","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":208,"y":540,"wires":[["aa24d69faa1640cd"]]},{"id":"aa24d69faa1640cd","type":"function","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"set msg.oauth2Request","func":"let refreshToken = global.get('refreshToken');\n\nmsg.oauth2Request = { \n \"access_token_url\": \"http://localhost:8080/v1/oauth/tokens\",\n \"credentials\": {\n \"grant_type\": \"refresh_token\",\n \"client_id\": \"test_client_1\",\n \"client_secret\": \"test_secret\",\n \"scope\": \"read_write\",\n \"refresh_token\": refreshToken \n },\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":438,"y":540,"wires":[["efd1a2a910ca1051"]]},{"id":"efd1a2a910ca1051","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"Set by msg.oauth2Request","container":"oauth2Response","grant_type":"set_by_credentials","access_token_url":"http://localhost:3000/oauth/token ","username":"pedroet","password":"","client_id":"confidentialApplication","client_secret":"topSecret","scope":"*","headers":{},"x":708,"y":540,"wires":[["a8fca004e704e071"]]},{"id":"a8fca004e704e071","type":"function","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":978,"y":540,"wires":[["9e9332c792dbdc01"]]},{"id":"9e9332c792dbdc01","type":"debug","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"DBG 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1187,"y":540,"wires":[]},{"id":"4030c52c.c2c29c","type":"inject","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"Refresh Token","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":218,"y":640,"wires":[["31727a2c.05a026"]]},{"id":"31727a2c.05a026","type":"function","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"SETTING REQUEST","func":"var REFRESH_TOKEN = global.get('refreshToken');\nvar ACCESS_TOKEN = global.get('accessToken');\n\nmsg.method = \"POST\"\nmsg.url = `http://localhost:8080/v1/oauth/tokens?grant_type=refresh_token&refresh_token=${REFRESH_TOKEN}`\n\nmsg.headers = {}\nmsg.headers[\"content-type\"] = \"application/json\"\nmsg.headers[\"Authorization\"] = 'Basic ' + Buffer.from('test_client_1:test_secret').toString('base64');\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":468,"y":640,"wires":[["64d9243f.b7be7c"]]},{"id":"64d9243f.b7be7c","type":"http request","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":798,"y":640,"wires":[["3b67977c.a53c08"]]},{"id":"3b67977c.a53c08","type":"debug","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"DBG 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1164,"y":640,"wires":[]},{"id":"1e2169485cd2be43","type":"function","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":220,"wires":[["d7a2041ef2683870"]]},{"id":"147aae5c70a7eecb","type":"function","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"set msg.oauth2Request","func":"msg.oauth2Request = { \n \"access_token_url\": \"http://localhost:8080/v1/oauth/tokens\",\n \"credentials\": {\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"test_client_1\",\n \"client_secret\": \"test_secret\",\n \"scope\": \"read_write\"\n },\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":280,"wires":[["10de26226e66ea9e"]]},{"id":"10de26226e66ea9e","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"Set by msg.oauth2Request","container":"oauth2Response","grant_type":"set_by_credentials","access_token_url":"http://localhost:3000/oauth/token ","authorization_endpoint":"","open_authentication":"","username":"pedroet","password":"","client_id":"confidentialApplication","client_secret":"topSecret","scope":"*","client_credentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":720,"y":280,"wires":[["1e2169485cd2be43"]]},{"id":"ca6a8cddea946ab2","type":"inject","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":280,"wires":[["147aae5c70a7eecb"]]},{"id":"8bd177259bc473f4","type":"function","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":100,"wires":[["d340377991d2d9b9"]]},{"id":"d340377991d2d9b9","type":"debug","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"DBG 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":100,"wires":[]},{"id":"5ff7fb2616706080","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"Set by msg.oauth2Request","container":"oauth2Response","grant_type":"set_by_credentials","access_token_url":"http://localhost:3000/oauth/token ","authorization_endpoint":"","open_authentication":"","username":"pedroet","password":"","client_id":"confidentialApplication","client_secret":"topSecret","scope":"*","client_credentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":720,"y":440,"wires":[["d857d0bc3e90d394"]]},{"id":"8eadc61e4e5b4ac2","type":"function","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"set msg.oauth2Request","func":"msg.oauth2Request = {\n \"access_token_url\": \"http://localhost:8080/v1/oauth/tokens\",\n \"credentials\": {\n \"grant_type\": \"password\",\n \"client_id\": \"test_client_1\",\n \"client_secret\": \"test_secret\",\n \"scope\": \"read_write\",\n \"username\": \"test@user\",\n \"password\": \"test_password\"\n },\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":440,"wires":[["5ff7fb2616706080"]]},{"id":"d857d0bc3e90d394","type":"function","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":380,"wires":[["dcbde702eae7191d"]]},{"id":"95745c4253c151f0","type":"inject","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":440,"wires":[["8eadc61e4e5b4ac2"]]},{"id":"dcbde702eae7191d","type":"debug","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"DBG 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":380,"wires":[]},{"id":"d6a9695a923ab18b","type":"inject","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":380,"wires":[["c5da03044bdca6f1"]]},{"id":"c5da03044bdca6f1","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"Password","container":"oauth2Response","grant_type":"password","access_token_url":"http://localhost:8080/v1/oauth/tokens","authorization_endpoint":"http://localhost:8080/web/authorize","redirect_uri":"/oauth2/redirect_uri","open_authentication":"41595d3b-a2b5-41aa-84e7-02d2c7b54304","username":"caputo.marcos@gmail.com","password":"123123","client_id":"test_client_1","client_secret":"test_secret","scope":"read_write","client_credentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":480,"y":380,"wires":[["d857d0bc3e90d394"]]}] +[{"id":"d15d33a4fa9a8ad9","type":"tab","label":"node-red-contrib-oauth2","disabled":false,"info":"","env":[]},{"id":"7e1a2f9059f99060","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"REFRESH","style":{"label":true,"stroke":"#7f7f7f","color":"#000000","fill":"#bfdbef"},"nodes":["d1ba341040cea0c3","aa24d69faa1640cd","efd1a2a910ca1051","a8fca004e704e071","9e9332c792dbdc01","7f22873286146e83"],"x":76,"y":499,"w":1210,"h":208},{"id":"7f22873286146e83","type":"group","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"via HTTP REQUEST","style":{"label":true},"nodes":["64d9243f.b7be7c","31727a2c.05a026","4030c52c.c2c29c","3b67977c.a53c08"],"x":102,"y":599,"w":1158,"h":82},{"id":"54025cb0a19e0f14","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Client Credentials","style":{"label":true,"stroke":"#a4a4a4","color":"#ffffff","fill":"#3f93cf"},"nodes":["10de26226e66ea9e","147aae5c70a7eecb","1e2169485cd2be43","ca6a8cddea946ab2","c6d4eb5c867902eb","d7a2041ef2683870","3f5a09c4fc8e769f"],"x":74,"y":179,"w":1212,"h":142},{"id":"f37b3410d0e03c57","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Authorization Code","style":{"label":true,"fill":"#3f93cf","color":"#ffffff"},"nodes":["8bd177259bc473f4","ee86852f62926632","d340377991d2d9b9","9e4d3edfde1766b9"],"x":74,"y":59,"w":1212,"h":82},{"id":"a783ce686ac81a0c","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Password","style":{"label":true,"fill":"#3f93cf","color":"#ffffff"},"nodes":["5ff7fb2616706080","8eadc61e4e5b4ac2","d857d0bc3e90d394","95745c4253c151f0","dcbde702eae7191d","d6a9695a923ab18b","c5da03044bdca6f1"],"x":74,"y":339,"w":1212,"h":142},{"id":"368ef084fe6b53de","type":"group","z":"d15d33a4fa9a8ad9","name":"Grant Type","style":{"label":true,"fill":"#bfc7d7","color":"#0070c0"},"nodes":["7e1a2f9059f99060","54025cb0a19e0f14","f37b3410d0e03c57","a783ce686ac81a0c"],"x":48,"y":33,"w":1264,"h":700},{"id":"ee86852f62926632","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"Authorization Code","container":"oauth2Response","grantType":"authorizationCode","accessTokenUrl":"http://localhost:8080/v1/oauth/tokens","authorizationEndpoint":"http://localhost:8080/web/authorize","redirectUri":"/oauth2/redirectUri","openAuthentication":"c9cf92ea-6f1d-44b6-86ed-6de1279f45d8","username":"","password":"","clientId":"test_client_1","clientSecret":"test_secret","scope":"read_write","clientCredentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":450,"y":100,"wires":[["8bd177259bc473f4"]]},{"id":"9e4d3edfde1766b9","type":"inject","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":100,"wires":[["ee86852f62926632"]]},{"id":"d7a2041ef2683870","type":"debug","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"DBG 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":220,"wires":[]},{"id":"c6d4eb5c867902eb","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"Client Credentials","container":"oauth2Response","grantType":"clientCredentials","accessTokenUrl":"http://localhost:8080/v1/oauth/tokens","authorizationEndpoint":"http://localhost:8080/web/authorize","redirectUri":"/oauth2/redirectUri","openAuthentication":"41595d3b-a2b5-41aa-84e7-02d2c7b54304","username":"","password":"","clientId":"test_client_1","clientSecret":"test_secret","scope":"read_write","clientCredentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":450,"y":220,"wires":[["1e2169485cd2be43"]]},{"id":"3f5a09c4fc8e769f","type":"inject","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":220,"wires":[["c6d4eb5c867902eb"]]},{"id":"d1ba341040cea0c3","type":"inject","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"Refresh Token","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3300","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":208,"y":540,"wires":[["aa24d69faa1640cd"]]},{"id":"aa24d69faa1640cd","type":"function","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"set msg.oauth2Request","func":"let refreshToken = global.get('refreshToken');\n\nmsg.oauth2Request = { \n \"accessTokenUrl\": \"http://localhost:8080/v1/oauth/tokens\",\n \"credentials\": {\n \"grantType\": \"refresh_token\",\n \"clientId\": \"test_client_1\",\n \"clientSecret\": \"test_secret\",\n \"scope\": \"read_write\",\n \"refresh_token\": refreshToken \n },\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":438,"y":540,"wires":[["efd1a2a910ca1051"]]},{"id":"efd1a2a910ca1051","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"Set by msg.oauth2Request","container":"oauth2Response","grantType":"setByCredentials","accessTokenUrl":"http://localhost:3000/oauth/token ","username":"pedroet","password":"","clientId":"confidentialApplication","clientSecret":"topSecret","scope":"*","headers":{},"x":708,"y":540,"wires":[["a8fca004e704e071"]]},{"id":"a8fca004e704e071","type":"function","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":978,"y":540,"wires":[["9e9332c792dbdc01"]]},{"id":"9e9332c792dbdc01","type":"debug","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"DBG 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1187,"y":540,"wires":[]},{"id":"4030c52c.c2c29c","type":"inject","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"Refresh Token","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":218,"y":640,"wires":[["31727a2c.05a026"]]},{"id":"31727a2c.05a026","type":"function","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"SETTING REQUEST","func":"var REFRESH_TOKEN = global.get('refreshToken');\nvar ACCESS_TOKEN = global.get('accessToken');\n\nmsg.method = \"POST\"\nmsg.url = `http://localhost:8080/v1/oauth/tokens?grantType=refresh_token&refresh_token=${REFRESH_TOKEN}`\n\nmsg.headers = {}\nmsg.headers[\"content-type\"] = \"application/json\"\nmsg.headers[\"Authorization\"] = 'Basic ' + Buffer.from('test_client_1:test_secret').toString('base64');\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":468,"y":640,"wires":[["64d9243f.b7be7c"]]},{"id":"64d9243f.b7be7c","type":"http request","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":798,"y":640,"wires":[["3b67977c.a53c08"]]},{"id":"3b67977c.a53c08","type":"debug","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"DBG 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1164,"y":640,"wires":[]},{"id":"1e2169485cd2be43","type":"function","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":220,"wires":[["d7a2041ef2683870"]]},{"id":"147aae5c70a7eecb","type":"function","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"set msg.oauth2Request","func":"msg.oauth2Request = { \n \"accessTokenUrl\": \"http://localhost:8080/v1/oauth/tokens\",\n \"credentials\": {\n \"grantType\": \"clientCredentials\",\n \"clientId\": \"test_client_1\",\n \"clientSecret\": \"test_secret\",\n \"scope\": \"read_write\"\n },\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":280,"wires":[["10de26226e66ea9e"]]},{"id":"10de26226e66ea9e","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"Set by msg.oauth2Request","container":"oauth2Response","grantType":"setByCredentials","accessTokenUrl":"http://localhost:3000/oauth/token ","authorizationEndpoint":"","openAuthentication":"","username":"pedroet","password":"","clientId":"confidentialApplication","clientSecret":"topSecret","scope":"*","clientCredentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":720,"y":280,"wires":[["1e2169485cd2be43"]]},{"id":"ca6a8cddea946ab2","type":"inject","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":280,"wires":[["147aae5c70a7eecb"]]},{"id":"8bd177259bc473f4","type":"function","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":100,"wires":[["d340377991d2d9b9"]]},{"id":"d340377991d2d9b9","type":"debug","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"DBG 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":100,"wires":[]},{"id":"5ff7fb2616706080","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"Set by msg.oauth2Request","container":"oauth2Response","grantType":"setByCredentials","accessTokenUrl":"http://localhost:3000/oauth/token ","authorizationEndpoint":"","openAuthentication":"","username":"pedroet","password":"","clientId":"confidentialApplication","clientSecret":"topSecret","scope":"*","clientCredentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":720,"y":440,"wires":[["d857d0bc3e90d394"]]},{"id":"8eadc61e4e5b4ac2","type":"function","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"set msg.oauth2Request","func":"msg.oauth2Request = {\n \"accessTokenUrl\": \"http://localhost:8080/v1/oauth/tokens\",\n \"credentials\": {\n \"grantType\": \"password\",\n \"clientId\": \"test_client_1\",\n \"clientSecret\": \"test_secret\",\n \"scope\": \"read_write\",\n \"username\": \"test@user\",\n \"password\": \"test_password\"\n },\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":440,"wires":[["5ff7fb2616706080"]]},{"id":"d857d0bc3e90d394","type":"function","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":380,"wires":[["dcbde702eae7191d"]]},{"id":"95745c4253c151f0","type":"inject","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":440,"wires":[["8eadc61e4e5b4ac2"]]},{"id":"dcbde702eae7191d","type":"debug","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"DBG 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":380,"wires":[]},{"id":"d6a9695a923ab18b","type":"inject","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":380,"wires":[["c5da03044bdca6f1"]]},{"id":"c5da03044bdca6f1","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"Password","container":"oauth2Response","grantType":"password","accessTokenUrl":"http://localhost:8080/v1/oauth/tokens","authorizationEndpoint":"http://localhost:8080/web/authorize","redirectUri":"/oauth2/redirectUri","openAuthentication":"41595d3b-a2b5-41aa-84e7-02d2c7b54304","username":"caputo.marcos@gmail.com","password":"123123","clientId":"test_client_1","clientSecret":"test_secret","scope":"read_write","clientCredentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":480,"y":380,"wires":[["d857d0bc3e90d394"]]}] ``` This sample used the [go-oauth2-server](https://github.com/RichardKnop/go-oauth2-server) implemented with GO (Golang). by [RichardKnop](https://github.com/RichardKnop) @@ -99,9 +99,9 @@ The `msg.oauth2Request` object contains the OAuth2 request details that are set The client credentials can be sent as part of the message payload to the node. The `msg.oauth2Request.credentials` object should contain the following properties: -- `grant_type` (string): This specifies the grant type. For dynamic credentials, the value should be set to "client_credentials". -- `client_id` (string): This is the client ID of the OAuth2 client. -- `client_secret` (string): This is the client secret of the OAuth2 client. +- `grantType` (string): This specifies the grant type. For dynamic credentials, the value should be set to "clientCredentials". +- `clientId` (string): This is the client ID of the OAuth2 client. +- `clientSecret` (string): This is the client secret of the OAuth2 client. - `scope` (string): This specifies the scope of the access requested. - `resource` (string): This specifies the resoure of the access requested. @@ -109,11 +109,11 @@ Here's an example: ```js msg.oauth2Request = { - access_token_url: "http://localhost:8080/v1/oauth/tokens", + accessTokenUrl: "http://localhost:8080/v1/oauth/tokens", credentials: { - grant_type: "client_credentials", - client_id: "test_client_1", - client_secret: "test_secret", + grantType: "clientCredentials", + clientId: "test_client_1", + clientSecret: "test_secret", scope: "read_write", }, }; @@ -124,9 +124,9 @@ return msg; The username and password can be sent as part of the message payload to the node. The `msg.oauth2Request.credentials` object should contain the following properties: -- `grant_type` (string): This specifies the grant type. For password credentials, the value should be set to "password". -- `client_id` (string): This is the client ID of the OAuth2 client. -- `client_secret` (string): This is the client secret of the OAuth2 client. +- `grantType` (string): This specifies the grant type. For password credentials, the value should be set to "password". +- `clientId` (string): This is the client ID of the OAuth2 client. +- `clientSecret` (string): This is the client secret of the OAuth2 client. - `scope` (string): This specifies the scope of the access requested. - `resource` (string): This specifies the resource of the access requested. - `username` (string): This is the username of the user. @@ -136,11 +136,11 @@ Here's an example: ```js msg.oauth2Request = { - access_token_url: "http://localhost:8080/v1/oauth/tokens", + accessTokenUrl: "http://localhost:8080/v1/oauth/tokens", credentials: { - grant_type: "password", - client_id: "test_client_1", - client_secret: "test_secret", + grantType: "password", + clientId: "test_client_1", + clientSecret: "test_secret", scope: "read_write", username: "test@user", password: "test_password", @@ -153,9 +153,9 @@ return msg; A refresh token can be used to obtain a new access token without requiring the user to re-authenticate. The `msg.oauth2Request.credentials` object should contain the following properties: -- `grant_type` (string): This specifies the grant type. For refresh token credentials, the value should be set to "refresh_token". -- `client_id` (string): This is the client ID of the OAuth2 client. -- `client_secret` (string): This is the client secret of the OAuth2 client. +- `grantType` (string): This specifies the grant type. For refresh token credentials, the value should be set to "refresh_token". +- `clientId` (string): This is the client ID of the OAuth2 client. +- `clientSecret` (string): This is the client secret of the OAuth2 client. - `scope` (string): This specifies the scope of the access requested. - `resource` (string): This specifies the resource of the access requested. - `refresh_token` (string): This is the refresh token obtained from a previous authentication. @@ -166,11 +166,11 @@ Here's an example: let refreshToken = global.get("refreshToken"); msg.oauth2Request = { - access_token_url: "http://localhost:8080/v1/oauth/tokens", + accessTokenUrl: "http://localhost:8080/v1/oauth/tokens", credentials: { - grant_type: "refresh_token", - client_id: "test_client_1", - client_secret: "test_secret", + grantType: "refresh_token", + clientId: "test_client_1", + clientSecret: "test_secret", scope: "read_write", refresh_token: refreshToken, }, diff --git a/examples/Sandbox PayPal - Client Credentials.json b/examples/Sandbox PayPal - Client Credentials.json index 1f67909..05cbba6 100644 --- a/examples/Sandbox PayPal - Client Credentials.json +++ b/examples/Sandbox PayPal - Client Credentials.json @@ -1 +1 @@ -[{"id":"3db3b0fd97716db6","type":"tab","label":"Sandbox PayPal - Client Credentials","disabled":false,"info":"","env":[]},{"id":"77cb8766f3d0f394","type":"group","z":"3db3b0fd97716db6","style":{"stroke":"#252525","stroke-opacity":"1","fill":"#333333","fill-opacity":"0.5","label":true,"label-position":"nw","color":"#dedede"},"nodes":["ba4c69bc6934eaf0","56941dc7fa2c9109","ea5f619acb7c6975","c6338a46953ce90f","0f0959f25b8ffac2","d501a2a68aed65ff","74cb073642513c64","b438631713b789b3","ba9065365539726b","7ae923df938ff7c2","2c022952654e4a88","7b99c317fa69b979","50f21b0248ad11fa","1e9fe7a88f8a9fd5","9f0816024a976737","23fd9bb05a9e0890","a5913a06e02ebba5","e398f17b55741fad"],"x":14,"y":19,"w":1032,"h":488},{"id":"a5913a06e02ebba5","type":"group","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#383c45","fill-opacity":"0.5","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["4a659fbacbd5a9ba","f7a09a555df4434c","4eb9ce10f8328334","ba768d993577dd9a","c22f0bf46fb98541"],"x":264,"y":359,"w":742,"h":122},{"id":"23fd9bb05a9e0890","type":"junction","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","x":620,"y":220,"wires":[["ba4c69bc6934eaf0"]]},{"id":"c22f0bf46fb98541","type":"junction","z":"3db3b0fd97716db6","g":"a5913a06e02ebba5","x":760,"y":440,"wires":[["ba768d993577dd9a","4eb9ce10f8328334"]]},{"id":"e398f17b55741fad","type":"junction","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","x":860,"y":160,"wires":[["ea5f619acb7c6975"]]},{"id":"ba4c69bc6934eaf0","type":"http request","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":730,"y":220,"wires":[["e398f17b55741fad"]]},{"id":"56941dc7fa2c9109","type":"function","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"POST credit-cards","func":"let token = global.get('token');\nmsg = {\n url: 'https://api.sandbox.paypal.com/v1/vault/credit-cards/',\n method: 'POST',\n headers: {\n content_type: 'application/json',\n authorization: `Bearer ${token}`\n },\n 'payload':{\n \"number\": \"4417119669820331\",\n \"type\": \"visa\",\n \"expire_month\": \"11\",\n \"expire_year\": \"2024\",\n \"first_name\": \"Joe\",\n \"last_name\": \"Shopper\",\n \"billing_address\": {\n \"line1\": \"52 N Main St.\",\n \"city\": \"Johnstown\",\n \"country_code\": \"US\",\n \"postal_code\": \"43210\",\n \"state\": \"OH\",\n \"phone\": \"408-334-8890\"\n }\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":140,"wires":[["23fd9bb05a9e0890"]]},{"id":"ea5f619acb7c6975","type":"debug","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":160,"wires":[]},{"id":"c6338a46953ce90f","type":"inject","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":140,"wires":[["56941dc7fa2c9109"]]},{"id":"0f0959f25b8ffac2","type":"function","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"set token","func":"global.set('token',msg.oauth2Response.access_token);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":120,"wires":[["e398f17b55741fad"]]},{"id":"d501a2a68aed65ff","type":"oauth2","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","container":"oauth2Response","grant_type":"client_credentials","access_token_url":"https://api.sandbox.paypal.com/v1/oauth2/token","username":"","password":"","client_id":"ATg1CMHw7GDbOH-XMd_IgzoksBNlvO_ieIyR-oBMoM_xiewyI7RrK8EOLMj438TAchfYtnVD6YeICHu2","client_secret":"EP2Xdc1ni1YGoT8EMiYPWQHhUDLrPM4oOitsEJShS4zmSKIEX0nfArtDtauxxhgnJd7BxLyOfEoIjow6","scope":"","headers":{},"x":450,"y":60,"wires":[["0f0959f25b8ffac2"]]},{"id":"74cb073642513c64","type":"inject","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":60,"wires":[["d501a2a68aed65ff"]]},{"id":"b438631713b789b3","type":"inject","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":220,"wires":[["ba9065365539726b"]]},{"id":"ba9065365539726b","type":"function","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"POST orders","func":"let token = global.get('token');\nmsg = {\n url: 'https://api-m.sandbox.paypal.com/v2/checkout/orders',\n method: 'POST',\n headers: {\n 'Content-type': 'application/json',\n 'Authorization': `Bearer ${token}`\n },\n 'payload':{\n \"intent\": \"CAPTURE\",\n \"purchase_units\": [\n {\n \"amount\": {\n \"currency_code\": \"USD\",\n \"value\": \"100.00\"\n }\n }\n ]\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":220,"wires":[["23fd9bb05a9e0890"]]},{"id":"7ae923df938ff7c2","type":"inject","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":260,"wires":[["2c022952654e4a88"]]},{"id":"2c022952654e4a88","type":"function","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"GET invoices","func":"let token = global.get('token');\nmsg = {\n url: 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices?total_required=true',\n method: 'GET',\n headers: {\n content_type: 'application/json',\n authorization: `Bearer ${token}`\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":260,"wires":[["23fd9bb05a9e0890"]]},{"id":"7b99c317fa69b979","type":"function","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"POST generate-next-invoice-number","func":"let token = global.get('token');\nmsg = {\n url: 'https://api-m.sandbox.paypal.com/v2/invoicing/generate-next-invoice-number',\n method: 'POST',\n headers: {\n content_type: 'application/json',\n authorization: `Bearer ${token}`\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":180,"wires":[["23fd9bb05a9e0890"]]},{"id":"50f21b0248ad11fa","type":"inject","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":180,"wires":[["7b99c317fa69b979"]]},{"id":"1e9fe7a88f8a9fd5","type":"function","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"GET webhooks","func":"let token = global.get('token');\nmsg = {\n url: 'https://api-m.sandbox.paypal.com/v1/notifications/webhooks',\n method: 'GET',\n headers: {\n content_type: 'application/json',\n authorization: `Bearer ${token}`\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":300,"wires":[["23fd9bb05a9e0890"]]},{"id":"9f0816024a976737","type":"inject","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":300,"wires":[["1e9fe7a88f8a9fd5"]]},{"id":"4a659fbacbd5a9ba","type":"http in","z":"3db3b0fd97716db6","g":"a5913a06e02ebba5","name":"","url":"/webhook","method":"post","upload":false,"swaggerDoc":"","x":380,"y":440,"wires":[["f7a09a555df4434c"]]},{"id":"f7a09a555df4434c","type":"function","z":"3db3b0fd97716db6","g":"a5913a06e02ebba5","name":"x-real-ip","func":"let ips = global.get('x-ip') || {};\n\nif ( msg.req.headers.host != \"localhost:1880\") {\n \n if (msg.req.headers[\"x-real-ip\"] in ips){\n ips[msg.req.headers[\"x-real-ip\"]] = ips[msg.req.headers[\"x-real-ip\"]] + 1;\n } else {\n ips[msg.req.headers[\"x-real-ip\"]] = 1;\n }\n \n global.set('X-Forwarded-For', msg.req.headers[\"X-Forwarded-For\"]);\n global.set('x-ip', ips);\n \n msg.payload = msg.req.headers[\"x-real-ip\"];\n msg.ip = msg.req.headers[\"x-real-ip\"];\n \n return msg;\n}\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":440,"wires":[["c22f0bf46fb98541"]],"icon":"node-red/alert.svg"},{"id":"4eb9ce10f8328334","type":"http response","z":"3db3b0fd97716db6","g":"a5913a06e02ebba5","name":"","statusCode":"200","headers":{},"x":920,"y":440,"wires":[]},{"id":"ba768d993577dd9a","type":"debug","z":"3db3b0fd97716db6","g":"a5913a06e02ebba5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":910,"y":400,"wires":[]}] \ No newline at end of file +[{"id":"3db3b0fd97716db6","type":"tab","label":"Sandbox PayPal - Client Credentials","disabled":false,"info":"","env":[]},{"id":"77cb8766f3d0f394","type":"group","z":"3db3b0fd97716db6","style":{"stroke":"#252525","stroke-opacity":"1","fill":"#333333","fill-opacity":"0.5","label":true,"label-position":"nw","color":"#dedede"},"nodes":["ba4c69bc6934eaf0","56941dc7fa2c9109","ea5f619acb7c6975","c6338a46953ce90f","0f0959f25b8ffac2","d501a2a68aed65ff","74cb073642513c64","b438631713b789b3","ba9065365539726b","7ae923df938ff7c2","2c022952654e4a88","7b99c317fa69b979","50f21b0248ad11fa","1e9fe7a88f8a9fd5","9f0816024a976737","23fd9bb05a9e0890","a5913a06e02ebba5","e398f17b55741fad"],"x":14,"y":19,"w":1032,"h":488},{"id":"a5913a06e02ebba5","type":"group","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#383c45","fill-opacity":"0.5","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["4a659fbacbd5a9ba","f7a09a555df4434c","4eb9ce10f8328334","ba768d993577dd9a","c22f0bf46fb98541"],"x":264,"y":359,"w":742,"h":122},{"id":"23fd9bb05a9e0890","type":"junction","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","x":620,"y":220,"wires":[["ba4c69bc6934eaf0"]]},{"id":"c22f0bf46fb98541","type":"junction","z":"3db3b0fd97716db6","g":"a5913a06e02ebba5","x":760,"y":440,"wires":[["ba768d993577dd9a","4eb9ce10f8328334"]]},{"id":"e398f17b55741fad","type":"junction","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","x":860,"y":160,"wires":[["ea5f619acb7c6975"]]},{"id":"ba4c69bc6934eaf0","type":"http request","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":730,"y":220,"wires":[["e398f17b55741fad"]]},{"id":"56941dc7fa2c9109","type":"function","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"POST credit-cards","func":"let token = global.get('token');\nmsg = {\n url: 'https://api.sandbox.paypal.com/v1/vault/credit-cards/',\n method: 'POST',\n headers: {\n content_type: 'application/json',\n authorization: `Bearer ${token}`\n },\n 'payload':{\n \"number\": \"4417119669820331\",\n \"type\": \"visa\",\n \"expire_month\": \"11\",\n \"expire_year\": \"2024\",\n \"first_name\": \"Joe\",\n \"last_name\": \"Shopper\",\n \"billing_address\": {\n \"line1\": \"52 N Main St.\",\n \"city\": \"Johnstown\",\n \"country_code\": \"US\",\n \"postal_code\": \"43210\",\n \"state\": \"OH\",\n \"phone\": \"408-334-8890\"\n }\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":140,"wires":[["23fd9bb05a9e0890"]]},{"id":"ea5f619acb7c6975","type":"debug","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":160,"wires":[]},{"id":"c6338a46953ce90f","type":"inject","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":140,"wires":[["56941dc7fa2c9109"]]},{"id":"0f0959f25b8ffac2","type":"function","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"set token","func":"global.set('token',msg.oauth2Response.access_token);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":120,"wires":[["e398f17b55741fad"]]},{"id":"d501a2a68aed65ff","type":"oauth2","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","container":"oauth2Response","grantType":"clientCredentials","accessTokenUrl":"https://api.sandbox.paypal.com/v1/oauth2/token","username":"","password":"","clientId":"ATg1CMHw7GDbOH-XMd_IgzoksBNlvO_ieIyR-oBMoM_xiewyI7RrK8EOLMj438TAchfYtnVD6YeICHu2","clientSecret":"EP2Xdc1ni1YGoT8EMiYPWQHhUDLrPM4oOitsEJShS4zmSKIEX0nfArtDtauxxhgnJd7BxLyOfEoIjow6","scope":"","headers":{},"x":450,"y":60,"wires":[["0f0959f25b8ffac2"]]},{"id":"74cb073642513c64","type":"inject","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":60,"wires":[["d501a2a68aed65ff"]]},{"id":"b438631713b789b3","type":"inject","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":220,"wires":[["ba9065365539726b"]]},{"id":"ba9065365539726b","type":"function","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"POST orders","func":"let token = global.get('token');\nmsg = {\n url: 'https://api-m.sandbox.paypal.com/v2/checkout/orders',\n method: 'POST',\n headers: {\n 'Content-type': 'application/json',\n 'Authorization': `Bearer ${token}`\n },\n 'payload':{\n \"intent\": \"CAPTURE\",\n \"purchase_units\": [\n {\n \"amount\": {\n \"currency_code\": \"USD\",\n \"value\": \"100.00\"\n }\n }\n ]\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":220,"wires":[["23fd9bb05a9e0890"]]},{"id":"7ae923df938ff7c2","type":"inject","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":260,"wires":[["2c022952654e4a88"]]},{"id":"2c022952654e4a88","type":"function","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"GET invoices","func":"let token = global.get('token');\nmsg = {\n url: 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices?total_required=true',\n method: 'GET',\n headers: {\n content_type: 'application/json',\n authorization: `Bearer ${token}`\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":260,"wires":[["23fd9bb05a9e0890"]]},{"id":"7b99c317fa69b979","type":"function","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"POST generate-next-invoice-number","func":"let token = global.get('token');\nmsg = {\n url: 'https://api-m.sandbox.paypal.com/v2/invoicing/generate-next-invoice-number',\n method: 'POST',\n headers: {\n content_type: 'application/json',\n authorization: `Bearer ${token}`\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":180,"wires":[["23fd9bb05a9e0890"]]},{"id":"50f21b0248ad11fa","type":"inject","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":180,"wires":[["7b99c317fa69b979"]]},{"id":"1e9fe7a88f8a9fd5","type":"function","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"GET webhooks","func":"let token = global.get('token');\nmsg = {\n url: 'https://api-m.sandbox.paypal.com/v1/notifications/webhooks',\n method: 'GET',\n headers: {\n content_type: 'application/json',\n authorization: `Bearer ${token}`\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":300,"wires":[["23fd9bb05a9e0890"]]},{"id":"9f0816024a976737","type":"inject","z":"3db3b0fd97716db6","g":"77cb8766f3d0f394","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":300,"wires":[["1e9fe7a88f8a9fd5"]]},{"id":"4a659fbacbd5a9ba","type":"http in","z":"3db3b0fd97716db6","g":"a5913a06e02ebba5","name":"","url":"/webhook","method":"post","upload":false,"swaggerDoc":"","x":380,"y":440,"wires":[["f7a09a555df4434c"]]},{"id":"f7a09a555df4434c","type":"function","z":"3db3b0fd97716db6","g":"a5913a06e02ebba5","name":"x-real-ip","func":"let ips = global.get('x-ip') || {};\n\nif ( msg.req.headers.host != \"localhost:1880\") {\n \n if (msg.req.headers[\"x-real-ip\"] in ips){\n ips[msg.req.headers[\"x-real-ip\"]] = ips[msg.req.headers[\"x-real-ip\"]] + 1;\n } else {\n ips[msg.req.headers[\"x-real-ip\"]] = 1;\n }\n \n global.set('X-Forwarded-For', msg.req.headers[\"X-Forwarded-For\"]);\n global.set('x-ip', ips);\n \n msg.payload = msg.req.headers[\"x-real-ip\"];\n msg.ip = msg.req.headers[\"x-real-ip\"];\n \n return msg;\n}\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":440,"wires":[["c22f0bf46fb98541"]],"icon":"node-red/alert.svg"},{"id":"4eb9ce10f8328334","type":"http response","z":"3db3b0fd97716db6","g":"a5913a06e02ebba5","name":"","statusCode":"200","headers":{},"x":920,"y":440,"wires":[]},{"id":"ba768d993577dd9a","type":"debug","z":"3db3b0fd97716db6","g":"a5913a06e02ebba5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":910,"y":400,"wires":[]}] \ No newline at end of file diff --git a/examples/node-red-contrib-oauth2.json b/examples/node-red-contrib-oauth2.json index 4f5671f..a31777b 100644 --- a/examples/node-red-contrib-oauth2.json +++ b/examples/node-red-contrib-oauth2.json @@ -1 +1 @@ -[{"id":"d15d33a4fa9a8ad9","type":"tab","label":"node-red-contrib-oauth2","disabled":false,"info":"","env":[]},{"id":"7e1a2f9059f99060","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"REFRESH","style":{"label":true,"stroke":"#7f7f7f","color":"#000000","fill":"#bfdbef"},"nodes":["d1ba341040cea0c3","aa24d69faa1640cd","efd1a2a910ca1051","a8fca004e704e071","9e9332c792dbdc01","7f22873286146e83"],"x":76,"y":499,"w":1210,"h":208},{"id":"7f22873286146e83","type":"group","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"via HTTP REQUEST","style":{"label":true},"nodes":["64d9243f.b7be7c","31727a2c.05a026","4030c52c.c2c29c","3b67977c.a53c08"],"x":102,"y":599,"w":1158,"h":82},{"id":"54025cb0a19e0f14","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Client Credentials","style":{"label":true,"stroke":"#a4a4a4","color":"#ffffff","fill":"#3f93cf"},"nodes":["10de26226e66ea9e","147aae5c70a7eecb","1e2169485cd2be43","ca6a8cddea946ab2","c6d4eb5c867902eb","d7a2041ef2683870","3f5a09c4fc8e769f"],"x":74,"y":179,"w":1212,"h":142},{"id":"f37b3410d0e03c57","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Authorization Code","style":{"label":true,"fill":"#3f93cf","color":"#ffffff"},"nodes":["8bd177259bc473f4","ee86852f62926632","d340377991d2d9b9","9e4d3edfde1766b9"],"x":74,"y":59,"w":1212,"h":82},{"id":"a783ce686ac81a0c","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Password","style":{"label":true,"fill":"#3f93cf","color":"#ffffff"},"nodes":["5ff7fb2616706080","8eadc61e4e5b4ac2","d857d0bc3e90d394","95745c4253c151f0","dcbde702eae7191d","d6a9695a923ab18b","c5da03044bdca6f1"],"x":74,"y":339,"w":1212,"h":142},{"id":"368ef084fe6b53de","type":"group","z":"d15d33a4fa9a8ad9","name":"Grant Type","style":{"label":true,"fill":"#bfc7d7","color":"#0070c0"},"nodes":["7e1a2f9059f99060","54025cb0a19e0f14","f37b3410d0e03c57","a783ce686ac81a0c"],"x":48,"y":33,"w":1264,"h":700},{"id":"ee86852f62926632","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"Authorization Code","container":"oauth2Response","grant_type":"authorization_code","access_token_url":"http://localhost:8080/v1/oauth/tokens","authorization_endpoint":"http://localhost:8080/web/authorize","redirect_uri":"/oauth2/redirect_uri","open_authentication":"c9cf92ea-6f1d-44b6-86ed-6de1279f45d8","username":"","password":"","client_id":"test_client_1","client_secret":"test_secret","scope":"read_write","client_credentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":450,"y":100,"wires":[["8bd177259bc473f4"]]},{"id":"9e4d3edfde1766b9","type":"inject","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":100,"wires":[["ee86852f62926632"]]},{"id":"d7a2041ef2683870","type":"debug","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"DBG 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":220,"wires":[]},{"id":"c6d4eb5c867902eb","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"Client Credentials","container":"oauth2Response","grant_type":"client_credentials","access_token_url":"http://localhost:8080/v1/oauth/tokens","authorization_endpoint":"http://localhost:8080/web/authorize","redirect_uri":"/oauth2/redirect_uri","open_authentication":"41595d3b-a2b5-41aa-84e7-02d2c7b54304","username":"","password":"","client_id":"test_client_1","client_secret":"test_secret","scope":"read_write","client_credentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":450,"y":220,"wires":[["1e2169485cd2be43"]]},{"id":"3f5a09c4fc8e769f","type":"inject","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":220,"wires":[["c6d4eb5c867902eb"]]},{"id":"d1ba341040cea0c3","type":"inject","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"Refresh Token","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3300","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":208,"y":540,"wires":[["aa24d69faa1640cd"]]},{"id":"aa24d69faa1640cd","type":"function","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"set msg.oauth2Request","func":"let refreshToken = global.get('refreshToken');\n\nmsg.oauth2Request = { \n \"access_token_url\": \"http://localhost:8080/v1/oauth/tokens\",\n \"credentials\": {\n \"grant_type\": \"refresh_token\",\n \"client_id\": \"test_client_1\",\n \"client_secret\": \"test_secret\",\n \"scope\": \"read_write\",\n \"refresh_token\": refreshToken \n },\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":438,"y":540,"wires":[["efd1a2a910ca1051"]]},{"id":"efd1a2a910ca1051","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"Set by msg.oauth2Request","container":"oauth2Response","grant_type":"set_by_credentials","access_token_url":"http://localhost:3000/oauth/token ","username":"pedroet","password":"","client_id":"confidentialApplication","client_secret":"topSecret","scope":"*","headers":{},"x":708,"y":540,"wires":[["a8fca004e704e071"]]},{"id":"a8fca004e704e071","type":"function","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":978,"y":540,"wires":[["9e9332c792dbdc01"]]},{"id":"9e9332c792dbdc01","type":"debug","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"DBG 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1187,"y":540,"wires":[]},{"id":"4030c52c.c2c29c","type":"inject","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"Refresh Token","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":218,"y":640,"wires":[["31727a2c.05a026"]]},{"id":"31727a2c.05a026","type":"function","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"SETTING REQUEST","func":"var REFRESH_TOKEN = global.get('refreshToken');\nvar ACCESS_TOKEN = global.get('accessToken');\n\nmsg.method = \"POST\"\nmsg.url = `http://localhost:8080/v1/oauth/tokens?grant_type=refresh_token&refresh_token=${REFRESH_TOKEN}`\n\nmsg.headers = {}\nmsg.headers[\"content-type\"] = \"application/json\"\nmsg.headers[\"Authorization\"] = 'Basic ' + Buffer.from('test_client_1:test_secret').toString('base64');\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":468,"y":640,"wires":[["64d9243f.b7be7c"]]},{"id":"64d9243f.b7be7c","type":"http request","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":798,"y":640,"wires":[["3b67977c.a53c08"]]},{"id":"3b67977c.a53c08","type":"debug","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"DBG 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1164,"y":640,"wires":[]},{"id":"1e2169485cd2be43","type":"function","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":220,"wires":[["d7a2041ef2683870"]]},{"id":"147aae5c70a7eecb","type":"function","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"set msg.oauth2Request","func":"msg.oauth2Request = { \n \"access_token_url\": \"http://localhost:8080/v1/oauth/tokens\",\n \"credentials\": {\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"test_client_1\",\n \"client_secret\": \"test_secret\",\n \"scope\": \"read_write\"\n },\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":280,"wires":[["10de26226e66ea9e"]]},{"id":"10de26226e66ea9e","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"Set by msg.oauth2Request","container":"oauth2Response","grant_type":"set_by_credentials","access_token_url":"http://localhost:3000/oauth/token ","authorization_endpoint":"","open_authentication":"","username":"pedroet","password":"","client_id":"confidentialApplication","client_secret":"topSecret","scope":"*","client_credentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":720,"y":280,"wires":[["1e2169485cd2be43"]]},{"id":"ca6a8cddea946ab2","type":"inject","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":280,"wires":[["147aae5c70a7eecb"]]},{"id":"8bd177259bc473f4","type":"function","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":100,"wires":[["d340377991d2d9b9"]]},{"id":"d340377991d2d9b9","type":"debug","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"DBG 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":100,"wires":[]},{"id":"5ff7fb2616706080","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"Set by msg.oauth2Request","container":"oauth2Response","grant_type":"set_by_credentials","access_token_url":"http://localhost:3000/oauth/token ","authorization_endpoint":"","open_authentication":"","username":"pedroet","password":"","client_id":"confidentialApplication","client_secret":"topSecret","scope":"*","client_credentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":720,"y":440,"wires":[["d857d0bc3e90d394"]]},{"id":"8eadc61e4e5b4ac2","type":"function","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"set msg.oauth2Request","func":"msg.oauth2Request = {\n \"access_token_url\": \"http://localhost:8080/v1/oauth/tokens\",\n \"credentials\": {\n \"grant_type\": \"password\",\n \"client_id\": \"test_client_1\",\n \"client_secret\": \"test_secret\",\n \"scope\": \"read_write\",\n \"username\": \"test@user\",\n \"password\": \"test_password\"\n },\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":440,"wires":[["5ff7fb2616706080"]]},{"id":"d857d0bc3e90d394","type":"function","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":380,"wires":[["dcbde702eae7191d"]]},{"id":"95745c4253c151f0","type":"inject","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":440,"wires":[["8eadc61e4e5b4ac2"]]},{"id":"dcbde702eae7191d","type":"debug","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"DBG 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":380,"wires":[]},{"id":"d6a9695a923ab18b","type":"inject","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":380,"wires":[["c5da03044bdca6f1"]]},{"id":"c5da03044bdca6f1","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"Password","container":"oauth2Response","grant_type":"password","access_token_url":"http://localhost:8080/v1/oauth/tokens","authorization_endpoint":"http://localhost:8080/web/authorize","redirect_uri":"/oauth2/redirect_uri","open_authentication":"41595d3b-a2b5-41aa-84e7-02d2c7b54304","username":"caputo.marcos@gmail.com","password":"123123","client_id":"test_client_1","client_secret":"test_secret","scope":"read_write","client_credentials_in_body":false,"rejectUnauthorized":true,"headers":{},"x":480,"y":380,"wires":[["d857d0bc3e90d394"]]}] +[{"id":"d15d33a4fa9a8ad9","type":"tab","label":"node-red-contrib-oauth2","disabled":false,"info":"","env":[]},{"id":"7e1a2f9059f99060","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"REFRESH","style":{"label":true,"stroke":"#7f7f7f","color":"#000000","fill":"#bfdbef"},"nodes":["d1ba341040cea0c3","aa24d69faa1640cd","efd1a2a910ca1051","a8fca004e704e071","9e9332c792dbdc01","7f22873286146e83"],"x":76,"y":499,"w":1210,"h":208},{"id":"7f22873286146e83","type":"group","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"via HTTP REQUEST","style":{"label":true},"nodes":["64d9243f.b7be7c","31727a2c.05a026","4030c52c.c2c29c","3b67977c.a53c08"],"x":102,"y":599,"w":1158,"h":82},{"id":"54025cb0a19e0f14","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Client Credentials","style":{"label":true,"stroke":"#a4a4a4","color":"#ffffff","fill":"#3f93cf"},"nodes":["10de26226e66ea9e","147aae5c70a7eecb","1e2169485cd2be43","ca6a8cddea946ab2","c6d4eb5c867902eb","d7a2041ef2683870","3f5a09c4fc8e769f"],"x":74,"y":179,"w":1212,"h":142},{"id":"f37b3410d0e03c57","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Authorization Code","style":{"label":true,"fill":"#3f93cf","color":"#ffffff"},"nodes":["8bd177259bc473f4","ee86852f62926632","d340377991d2d9b9","9e4d3edfde1766b9"],"x":74,"y":59,"w":1212,"h":82},{"id":"a783ce686ac81a0c","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Password","style":{"label":true,"fill":"#3f93cf","color":"#ffffff"},"nodes":["5ff7fb2616706080","8eadc61e4e5b4ac2","d857d0bc3e90d394","95745c4253c151f0","dcbde702eae7191d","d6a9695a923ab18b","c5da03044bdca6f1"],"x":74,"y":339,"w":1212,"h":142},{"id":"368ef084fe6b53de","type":"group","z":"d15d33a4fa9a8ad9","name":"Grant Type","style":{"label":true,"fill":"#bfc7d7","color":"#0070c0"},"nodes":["7e1a2f9059f99060","54025cb0a19e0f14","f37b3410d0e03c57","a783ce686ac81a0c"],"x":48,"y":33,"w":1264,"h":700},{"id":"ee86852f62926632","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"Authorization Code","container":"oauth2Response","grantType":"authorizationCode","accessTokenUrl":"http://localhost:8080/v1/oauth/tokens","authorizationEndpoint":"http://localhost:8080/web/authorize","redirectUri":"/oauth2/redirectUri","openAuthentication":"c9cf92ea-6f1d-44b6-86ed-6de1279f45d8","username":"","password":"","clientId":"test_client_1","clientSecret":"test_secret","scope":"read_write","clientCredentialsInBody":false,"rejectUnauthorized":true,"headers":{},"x":450,"y":100,"wires":[["8bd177259bc473f4"]]},{"id":"9e4d3edfde1766b9","type":"inject","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":100,"wires":[["ee86852f62926632"]]},{"id":"d7a2041ef2683870","type":"debug","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"DBG 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":220,"wires":[]},{"id":"c6d4eb5c867902eb","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"Client Credentials","container":"oauth2Response","grantType":"clientCredentials","accessTokenUrl":"http://localhost:8080/v1/oauth/tokens","authorizationEndpoint":"http://localhost:8080/web/authorize","redirectUri":"/oauth2/redirectUri","openAuthentication":"41595d3b-a2b5-41aa-84e7-02d2c7b54304","username":"","password":"","clientId":"test_client_1","clientSecret":"test_secret","scope":"read_write","clientCredentialsInBody":false,"rejectUnauthorized":true,"headers":{},"x":450,"y":220,"wires":[["1e2169485cd2be43"]]},{"id":"3f5a09c4fc8e769f","type":"inject","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":220,"wires":[["c6d4eb5c867902eb"]]},{"id":"d1ba341040cea0c3","type":"inject","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"Refresh Token","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3300","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":208,"y":540,"wires":[["aa24d69faa1640cd"]]},{"id":"aa24d69faa1640cd","type":"function","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"set msg.oauth2Request","func":"let refreshToken = global.get('refreshToken');\n\nmsg.oauth2Request = { \n \"accessTokenUrl\": \"http://localhost:8080/v1/oauth/tokens\",\n \"credentials\": {\n \"grantType\": \"refresh_token\",\n \"clientId\": \"test_client_1\",\n \"clientSecret\": \"test_secret\",\n \"scope\": \"read_write\",\n \"refresh_token\": refreshToken \n },\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":438,"y":540,"wires":[["efd1a2a910ca1051"]]},{"id":"efd1a2a910ca1051","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"Set by msg.oauth2Request","container":"oauth2Response","grantType":"setByCredentials","accessTokenUrl":"http://localhost:3000/oauth/token ","username":"pedroet","password":"","clientId":"confidentialApplication","clientSecret":"topSecret","scope":"*","headers":{},"x":708,"y":540,"wires":[["a8fca004e704e071"]]},{"id":"a8fca004e704e071","type":"function","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":978,"y":540,"wires":[["9e9332c792dbdc01"]]},{"id":"9e9332c792dbdc01","type":"debug","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"DBG 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1187,"y":540,"wires":[]},{"id":"4030c52c.c2c29c","type":"inject","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"Refresh Token","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":218,"y":640,"wires":[["31727a2c.05a026"]]},{"id":"31727a2c.05a026","type":"function","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"SETTING REQUEST","func":"var REFRESH_TOKEN = global.get('refreshToken');\nvar ACCESS_TOKEN = global.get('accessToken');\n\nmsg.method = \"POST\"\nmsg.url = `http://localhost:8080/v1/oauth/tokens?grantType=refresh_token&refresh_token=${REFRESH_TOKEN}`\n\nmsg.headers = {}\nmsg.headers[\"content-type\"] = \"application/json\"\nmsg.headers[\"Authorization\"] = 'Basic ' + Buffer.from('test_client_1:test_secret').toString('base64');\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":468,"y":640,"wires":[["64d9243f.b7be7c"]]},{"id":"64d9243f.b7be7c","type":"http request","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":798,"y":640,"wires":[["3b67977c.a53c08"]]},{"id":"3b67977c.a53c08","type":"debug","z":"d15d33a4fa9a8ad9","g":"7f22873286146e83","name":"DBG 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1164,"y":640,"wires":[]},{"id":"1e2169485cd2be43","type":"function","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":220,"wires":[["d7a2041ef2683870"]]},{"id":"147aae5c70a7eecb","type":"function","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"set msg.oauth2Request","func":"msg.oauth2Request = { \n \"accessTokenUrl\": \"http://localhost:8080/v1/oauth/tokens\",\n \"credentials\": {\n \"grantType\": \"clientCredentials\",\n \"clientId\": \"test_client_1\",\n \"clientSecret\": \"test_secret\",\n \"scope\": \"read_write\"\n },\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":280,"wires":[["10de26226e66ea9e"]]},{"id":"10de26226e66ea9e","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"Set by msg.oauth2Request","container":"oauth2Response","grantType":"setByCredentials","accessTokenUrl":"http://localhost:3000/oauth/token ","authorizationEndpoint":"","openAuthentication":"","username":"pedroet","password":"","clientId":"confidentialApplication","clientSecret":"topSecret","scope":"*","clientCredentialsInBody":false,"rejectUnauthorized":true,"headers":{},"x":720,"y":280,"wires":[["1e2169485cd2be43"]]},{"id":"ca6a8cddea946ab2","type":"inject","z":"d15d33a4fa9a8ad9","g":"54025cb0a19e0f14","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":280,"wires":[["147aae5c70a7eecb"]]},{"id":"8bd177259bc473f4","type":"function","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":100,"wires":[["d340377991d2d9b9"]]},{"id":"d340377991d2d9b9","type":"debug","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57","name":"DBG 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":100,"wires":[]},{"id":"5ff7fb2616706080","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"Set by msg.oauth2Request","container":"oauth2Response","grantType":"setByCredentials","accessTokenUrl":"http://localhost:3000/oauth/token ","authorizationEndpoint":"","openAuthentication":"","username":"pedroet","password":"","clientId":"confidentialApplication","clientSecret":"topSecret","scope":"*","clientCredentialsInBody":false,"rejectUnauthorized":true,"headers":{},"x":720,"y":440,"wires":[["d857d0bc3e90d394"]]},{"id":"8eadc61e4e5b4ac2","type":"function","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"set msg.oauth2Request","func":"msg.oauth2Request = {\n \"accessTokenUrl\": \"http://localhost:8080/v1/oauth/tokens\",\n \"credentials\": {\n \"grantType\": \"password\",\n \"clientId\": \"test_client_1\",\n \"clientSecret\": \"test_secret\",\n \"scope\": \"read_write\",\n \"username\": \"test@user\",\n \"password\": \"test_password\"\n },\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":440,"wires":[["5ff7fb2616706080"]]},{"id":"d857d0bc3e90d394","type":"function","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"Set refreshToken","func":"if (msg.oauth2Response.refresh_token) {\n global.set('refreshToken', msg.oauth2Response.refresh_token);\n}\nif (msg.oauth2Response.access_token) {\n global.set('accessToken', msg.oauth2Response.access_token);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":380,"wires":[["dcbde702eae7191d"]]},{"id":"95745c4253c151f0","type":"inject","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":440,"wires":[["8eadc61e4e5b4ac2"]]},{"id":"dcbde702eae7191d","type":"debug","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"DBG 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":380,"wires":[]},{"id":"d6a9695a923ab18b","type":"inject","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":380,"wires":[["c5da03044bdca6f1"]]},{"id":"c5da03044bdca6f1","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"a783ce686ac81a0c","name":"Password","container":"oauth2Response","grantType":"password","accessTokenUrl":"http://localhost:8080/v1/oauth/tokens","authorizationEndpoint":"http://localhost:8080/web/authorize","redirectUri":"/oauth2/redirectUri","openAuthentication":"41595d3b-a2b5-41aa-84e7-02d2c7b54304","username":"caputo.marcos@gmail.com","password":"123123","clientId":"test_client_1","clientSecret":"test_secret","scope":"read_write","clientCredentialsInBody":false,"rejectUnauthorized":true,"headers":{},"x":480,"y":380,"wires":[["d857d0bc3e90d394"]]}] diff --git a/src/locales/en-US/oauth2.html b/src/locales/en-US/oauth2.html index f51b078..2e7a12a 100644 --- a/src/locales/en-US/oauth2.html +++ b/src/locales/en-US/oauth2.html @@ -76,9 +76,9 @@ The client credentials can be sent as part of the message payload to the node. The `msg.oauth2Request.credentials` object should contain the following properties: - - `grant_type` (string): This specifies the grant type. For dynamic credentials, the value should be set to "client_credentials". - - `client_id` (string): This is the client ID of the OAuth2 client. - - `client_secret` (string): This is the client secret of the OAuth2 client. + - `grantType` (string): This specifies the grant type. For dynamic credentials, the value should be set to "clientCredentials". + - `clientId` (string): This is the client ID of the OAuth2 client. + - `clientSecret` (string): This is the client secret of the OAuth2 client. - `scope` (string): This specifies the scope of the access requested. - `resource` (string): This specifies the resource of the access requested. @@ -86,11 +86,11 @@ ```js msg.oauth2Request = { - access_token_url: 'http://localhost:8080/v1/oauth/tokens', + accessTokenUrl: 'http://localhost:8080/v1/oauth/tokens', credentials: { - grant_type: 'client_credentials', - client_id: 'test_client_1', - client_secret: 'test_secret', + grantType: 'clientCredentials', + clientId: 'test_client_1', + clientSecret: 'test_secret', scope: 'read_write', resource: 'http://localhost:8080' } @@ -102,9 +102,9 @@ The username and password can be sent as part of the message payload to the node. The `msg.oauth2Request.credentials` object should contain the following properties: - - `grant_type` (string): This specifies the grant type. For password credentials, the value should be set to "password". - - `client_id` (string): This is the client ID of the OAuth2 client. - - `client_secret` (string): This is the client secret of the OAuth2 client. + - `grantType` (string): This specifies the grant type. For password credentials, the value should be set to "password". + - `clientId` (string): This is the client ID of the OAuth2 client. + - `clientSecret` (string): This is the client secret of the OAuth2 client. - `scope` (string): This specifies the scope of the access requested. - `resource` (string): This specifies the resource of the access requested. - `username` (string): This is the username of the user. @@ -114,11 +114,11 @@ ```js msg.oauth2Request = { - access_token_url: 'http://localhost:8080/v1/oauth/tokens', + accessTokenUrl: 'http://localhost:8080/v1/oauth/tokens', credentials: { - grant_type: 'password', - client_id: 'test_client_1', - client_secret: 'test_secret', + grantType: 'password', + clientId: 'test_client_1', + clientSecret: 'test_secret', scope: 'read_write', resource: 'http://localhost:8080', username: 'test@user', @@ -132,9 +132,9 @@ A refresh token can be used to obtain a new access token without requiring the user to re-authenticate. The `msg.oauth2Request.credentials` object should contain the following properties: - - `grant_type` (string): This specifies the grant type. For refresh token credentials, the value should be set to "refresh_token". - - `client_id` (string): This is the client ID of the OAuth2 client. - - `client_secret` (string): This is the client secret of the OAuth2 client. + - `grantType` (string): This specifies the grant type. For refresh token credentials, the value should be set to "refresh_token". + - `clientId` (string): This is the client ID of the OAuth2 client. + - `clientSecret` (string): This is the client secret of the OAuth2 client. - `scope` (string): This specifies the scope of the access requested. - `resource` (string): This specifies the resource of the access requested. - `refresh_token` (string): This is the refresh token obtained from a previous authentication. @@ -145,11 +145,11 @@ let refreshToken = global.get('refreshToken'); msg.oauth2Request = { - access_token_url: 'http://localhost:8080/v1/oauth/tokens', + accessTokenUrl: 'http://localhost:8080/v1/oauth/tokens', credentials: { - grant_type: 'refresh_token', - client_id: 'test_client_1', - client_secret: 'test_secret', + grantType: 'refresh_token', + clientId: 'test_client_1', + clientSecret: 'test_secret', scope: 'read_write', resource: 'http://localhost:8080', refresh_token: refreshToken diff --git a/src/locales/en-US/oauth2.json b/src/locales/en-US/oauth2.json index d543d2d..11491a3 100644 --- a/src/locales/en-US/oauth2.json +++ b/src/locales/en-US/oauth2.json @@ -2,24 +2,24 @@ "oauth2": { "oauth2": "oauth2", "label": { - "grant_type": "Grant Type", + "grantType": "Grant Type", "name": "Name", "container": "Container", - "access_token_url": "Access Token URL", - "authorization_endpoint": "Authorization Endpoint", - "redirect_uri": "Redirect URI", - "open_authentication": "Code", + "accessTokenUrl": "Access Token URL", + "authorizationEndpoint": "Authorization Endpoint", + "redirectUri": "Redirect URI", + "openAuthentication": "Code", "username": "Username", "password": "Password", - "client_id": "Client ID", - "client_secret": "Client Secret", + "clientId": "Client ID", + "clientSecret": "Client Secret", "scope": "Scope", "resource": "Resource", "state": "State", "rejectUnauthorized": "The rejectUnauthorized parameter controls SSL/TLS certificate validation for the server, with true enforcing validation and false disabling it.", "rejectUnauthorized_label": "Reject Unauthorized", - "client_credentials_in_body": "Ensure that the client credentials are included in the token request body for authentication purposes.", - "client_credentials_in_body_label": "Embedded Credentials", + "clientCredentialsInBody": "Ensure that the client credentials are included in the token request body for authentication purposes.", + "clientCredentialsInBody_label": "Embedded Credentials", "proxy-config": "Proxy Configuration", "use-proxy": "Use proxy", "senderr": "Only send non-2xx responses to Catch node" @@ -27,14 +27,14 @@ "placeholder": { "name": "oauth2", "container": "oauth2Response", - "access_token_url": "https://github.com/login/oauth/access_token", - "authorization_endpoint": "https://github.com/login/oauth/authorize", - "redirect_uri": "/oauth2/redirect", - "open_authentication": "1b897416-3de3-4631-a0e9-7f7431e1a959", + "accessTokenUrl": "https://github.com/login/oauth/access_token", + "authorizationEndpoint": "https://github.com/login/oauth/authorize", + "redirectUri": "/oauth2/redirect", + "openAuthentication": "1b897416-3de3-4631-a0e9-7f7431e1a959", "username": "admin", "password": "admin", - "client_id": "012493af6282be51660dbc8e21a8462e", - "client_secret": "5621bd4b5a8b09ed31817efb8d54fda2c72bfc1c6968cd4563d83f7cc26f68f6", + "clientId": "012493af6282be51660dbc8e21a8462e", + "clientSecret": "5621bd4b5a8b09ed31817efb8d54fda2c72bfc1c6968cd4563d83f7cc26f68f6", "scope": "scope", "resource": "resource", "state": "state", @@ -42,10 +42,10 @@ "headers": "headers" }, "opts": { - "client_credentials": "Client Credentials", - "password_credentials": "Password", - "authorization_code": "Authorization Code", - "set_by_credentials": "- Set by msg.oauth2Request -" + "clientCredentials": "Client Credentials", + "passwordCredentials": "Password", + "authorizationCode": "Authorization Code", + "setByCredentials": "- Set by msg.oauth2Request -" } } } diff --git a/src/oauth2.html b/src/oauth2.html index d89b88c..41edbe2 100644 --- a/src/oauth2.html +++ b/src/oauth2.html @@ -9,28 +9,28 @@ - +