Forum

Browse topics, discover Works With Legrand community!

issue requesting refresh token using nodered

Hi, I can successfully generate a refresh token using postman but I doesn’t work using Nodered. any idea’s?

I am using the following API: <span style=”color: #505050; font-family: OpenSans, Helvetica, Arial, sans-serif; font-size: 12px; white-space: pre-wrap;”>https://partners-login.eliotbylegrand.com/token using the following body params: client_id, client_secret, grant_type and refresh_token.</span>

When I use it in Post man, I got an 200 OK, using nodered, I get<span class=”red-ui-debug-msg-object-key” style=”font-family: Menlo, Consolas, ‘DejaVu Sans Mono’, Courier, monospace; font-size: 13px; color: #792e90;”>error</span><span style=”background-color: #efefef; font-family: Menlo, Consolas, ‘DejaVu Sans Mono’, Courier, monospace; font-size: 13px;”>:</span><span style=”background-color: #efefef; font-family: Menlo, Consolas, ‘DejaVu Sans Mono’, Courier, monospace; font-size: 13px;”> </span><span class=”red-ui-debug-msg-object-value” style=”font-family: Menlo, Consolas, ‘DejaVu Sans Mono’, Courier, monospace; font-size: 13px;”><span class=”red-ui-debug-msg-type-string red-ui-debug-msg-object-header” style=”color: #b72828; white-space: pre-wrap;”>”server_error”</span></span>
<div class=”red-ui-debug-msg-object-entry collapsed” style=”position: relative; padding-left: 15px; font-family: Menlo, Consolas, ‘DejaVu Sans Mono’, Courier, monospace; font-size: 13px;”><span class=”red-ui-debug-msg-element” style=”line-height: 1.3em; overflow-wrap: break-word;”><span class=”red-ui-debug-msg-row” style=”display: block; padding: 4px 2px 2px; position: relative;”><span class=”red-ui-debug-msg-object-key” style=”color: #792e90;”>error_description</span>: <span class=”red-ui-debug-msg-object-value”><span class=”red-ui-debug-msg-type-string red-ui-debug-msg-object-header” style=”color: #b72828; white-space: pre-wrap;”>”An unexpected server error occurred”</span></span></span></span></div>
<div></div>
<div>Can’t find the difference. Any help would be appreciated. i uploaded an image of the debug window and copied the flow below:</div>
<div>[{“id”:”d6644353.62e9b”,”type”:”change”,”z”:”838a9b3f.571d18″,”name”:”Prepare request”,”rules”:[{“t”:”set”,”p”:”payload”,”pt”:”msg”,”to”:”{}”,”tot”:”json”},{“t”:”set”,”p”:”payload.grant_type”,”pt”:”msg”,”to”:”refresh_token”,”tot”:”str”},{“t”:”set”,”p”:”payload.refresh_token”,”pt”:”msg”,”to”:”eyJraWQiOiJjcGltY29yZV8wOTI1MjAxNSIsInZlciI6IjEuMCIsInppcCI6IkRlZmxhdGUiLCJzZXIiOiIxLjAifQ..oJPLiUqnNpTvySru.bVMHIXdcpPKSppZlX_swjkYlohSk5zkgg5b_7pXQaYwDhmY_Z5o1EYN2fnBtv5wG0U-QWUOITA8kBDoZJQlJuHe6gTFdyGY5knPsO_rD3iiGRflilvpIcgQtLHVLguOAjbAOyYZVxCLfXeWcuYOy0EcrR_VYbpeogNyOi8E7aA3F_hvfZhsojzBek9Kk-2VcP8aB2g7FQe8qeCr2Tzl3v3mpQQnMXX_ls3VikLBTGQk-77htGgTze7RHwJwSp_1O7yFMk4c5wNmscpBaskxl18buq1dCLUENAGY66074EmvuHSOIaZtOeCsOoIeUwqRaew8WujZ1io70rbEElp3-XgPouAK0IqIjau6F0wGSgnuRvHE1Vjys7iFJQ8qLZsBYMzuKpN_zEJIkT1-yzt7KFKfI-yjj9yzdDi_PKBZSoSnpMgbZ_4EWlhqCdO1tVtt_PGMuzYwisYZCbnI65Z1Iz9FEeWMIb8yA8hxzqd8DgKC77OJZp_X8aaNznPfsJgrm3oA1F-KA0wc5MQrR_szqYNNArfgN45MQe26inT1eqW5TxxokDSTEWaGPJud4dy6J89C7eBkxuadHrYLCQ45upAhltsGBESR99ZSFsqfHBhjLJpnqCo1E2ygItA_m7Gux0gvBbpBtLdhPL8IwtGiD3ptGGC3qCqpPVniRzXdKHsNeJKetKu_kElRg-eOlYtQsalMl8VPmMMm4gwOF75x-SFHUNHb_vdRu76QZXY-R6iZkvPj8zNkKvlDBzqtbdKqmPVpk4VJaljoBKNcIx7eMmGNfnxpALEX-rzUJYVh2DNrEf-FWWJ5dS5inkv2V__SdUM9JdFyaaI949bBHdA0cFXvl_VHR8JdhM_lUOPrLLAMK5VH7qXJKiu3UKNbhpuW8.E0QwEBDh5RR91QfzLxN5jw”,”tot”:”str”},{“t”:”set”,”p”:”payload.client_id”,”pt”:”msg”,”to”:”removed for security”,”tot”:”str”},{“t”:”set”,”p”:”payload.client_secret”,”pt”:”msg”,”to”:”removed for security”,”tot”:”str”}],”action”:””,”property”:””,”from”:””,”to”:””,”reg”:false,”x”:240,”y”:100,”wires”:[[“bdc07e1f.e38c5″,”94d84c05.cb7b4”]]}]</div>

Hi Peter,

I don’t know much about NodeRed, but this error looks like a Content-Type one for the Body (it must be “form-data”)

Here is an example of what I get for this in Body for a NodeJS request :

formData: {
    ‘client_id’: ‘3dd212XX-XXXXXXXXXX’,
    ‘grant_type’: ‘refresh_token’,
    ‘refresh_token’: ‘eyJraWQiOiJjcGltY29yZV8wO……….’,
    ‘client_secret’: ‘r+.XXXXXXXXXX’
 }

 

Hoping it will help you to solve this issue,

Have a good day,

Leslie – Community Manager

found the issue, have to add the following msg header

<code style=”font-family: Consolas, Menlo, Monaco, ‘Lucida Console’, ‘Liberation Mono’, ‘DejaVu Sans Mono’, ‘Bitstream Vera Sans Mono’, ‘Courier New’, monospace; font-size: 15.008px; color: #910000; background-color: #f0f0f0; padding: 3px;”>msg.headers[“content-type”]<span style=”color: #222222; font-family: Arial, sans-serif; font-size: 15.008px; background-color: #f9f9f9;”> should be set to </span><code style=”font-family: Consolas, Menlo, Monaco, ‘Lucida Console’, ‘Liberation Mono’, ‘DejaVu Sans Mono’, ‘Bitstream Vera Sans Mono’, ‘Courier New’, monospace; font-size: 15.008px; color: #910000; background-color: #f0f0f0; padding: 3px;”>application/x-www-form-urlencoded<span style=”color: #222222; font-family: Arial, sans-serif; font-size: 15.008px; background-color: #f9f9f9;”>.</span>

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.