I've read various posts here on the node-red way to provide data to an http-request node, but no matter what I try I am not getting anywhere fast.
(Because this contains sensitive data, I have had to obscure or modify certain parts.)
Running this:
curl -s "https://auth.xxx.com/oauth/token" -d client_id=xxx-web-app -d grant_type=password -d scope=home.user -d username="xxx@xxx.com" -d password="pet-syp-bom" -d client_secret="wZaRN7rpjn3FoNyF5IFuxg9uMzYJcvOoQ8QWiIqS3hfk6gLhVlG57j5YNoZL2Rtc"
Gets the expected:
{"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1OTVlNDUxMDA5OGYzMzI1MGFkYzE2MzMiLCJ6b25laW5mbyI6IkV1cm9wZS9Mb25kb24iLCJ0YWRvX2hvbWVzIjpbeyJpZCI6MTg4MX1dLCJpc3MiOiJ0YWRvIiwibG9jYWxlIjoiZW4iLCJhdWQiOiJwYXJ0bmVyIiwibmJmIjoxNjU2NTc1NjAzLCJ0YWRvX3Njb3BlIjpbImhvbWUudXNlciJdLCJ0YWRvX3VzZXJuYW1lIjoiYmVybmFyZGhhcnRlQG1hYy5jb20iLCJuYW1lIjoiQmVybmFyZCBIYXJ0ZSIsImV4cCI6MTY1NjU3NjIwMywiaWF0IjoxNjU2NTc1NjAzLCJ0YWRvX2NsaWVudF9pZCI6InRhZG8td2ViLWFwcCIsImp0aSI6ImZmODBlYzMyLTRlMzgtNDVlNS05MjQ2LTFmNDY3ZWY1ZjJkZSIsImVtYWlsIjoiYmVybmFyZGhhcnRlQG1hYy5jb20ifQ.QYzV7vuCaso-3iV5or10ZRBuk44MmAYcAiy-8W7SAD8_Dkg6gvrSvK7m0I8lMdOF8kjCq8HaCs5h1J9IEeUHm2CHks86Vf3dzu8anOztk9S4J98RlUGrgND2PKsGNL69ZdILNASnRhImlz75isHYpGbond1e_PpI8ypQ9tG-WpvR0nBf7MrX64MwSLxDzUWMhSOXcQTHXE8WZFT3NcQiEOnp05QA_dyY57PLsDTyydE--IbFNsW36ZuC_S8gtfbM40X7eUIyp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":"home.user",
"jti":"ff80ec32-4e38-45e5-9246-1f467ef5f2de"
When I try implementing (what I think is) the same in node-red [see below], I get an error: "invalid_grant" and error_description: "Bad credentials", so perhaps I am providing the username and password and/or the client_secret in the wrong place?
Any help would be much appreciated!
[
{
"id": "35bdb008ec1bf921",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "5ca4e10a17fb8bd0",
"type": "inject",
"z": "35bdb008ec1bf921",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 200,
"y": 120,
"wires": [
[
"ce7a4b98b74cd230"
]
]
},
{
"id": "ce7a4b98b74cd230",
"type": "change",
"z": "35bdb008ec1bf921",
"name": "",
"rules": [
{
"t": "set",
"p": "headers",
"pt": "msg",
"to": "{\"content-type\":\"application/x-www-form-urlencoded\"}",
"tot": "json"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"client_id\":\"xxx-web-app\",\"grant_type\":\"password\",\"scope\":\"home.user\",\"username\":\"xxx@xxx.com\",\"password\":\"pet-syp-bom\",\"client_secret\":\"wZaRN7rpjn3FoNyF5IFuxg9uMzYJcvOoQ8QWiIqS3hfk6gLhVlG57j5YNoZL2Rtc\"}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 340,
"y": 180,
"wires": [
[
"814f9dbe9af659cf"
]
]
},
{
"id": "814f9dbe9af659cf",
"type": "http request",
"z": "35bdb008ec1bf921",
"name": "",
"method": "POST",
"ret": "obj",
"paytoqs": "query",
"url": "https://auth.xxx.com/oauth/token",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 450,
"y": 260,
"wires": [
[
"7fe5d3240debc20a"
]
]
},
{
"id": "7fe5d3240debc20a",
"type": "debug",
"z": "35bdb008ec1bf921",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 590,
"y": 320,
"wires": []
}
]