HTTP Request - Bearer Token truncated

Hello, I am new so please go gentle on me.
I am having trouble receiving a complete/working bearer token from a HTTP request. I can use a cURL command external to Node-RED and all is ok and receive a code 200 along with a working access_token(Bearer). However when I set it up in Node-RED the returned bearer (although I'm still getting a code 200) it appears to be truncated as I see a ..." at the end of the token. I attempt to use the token in the vendors swagger API and it fails. So I presume the token is truncated for some reason.

Here is my cleaned flow if helps:

[{"id":"78b25d40d6476ca8","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"0bcf9a6d922fb05d","type":"inject","z":"78b25d40d6476ca8","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":160,"wires":[["c6cca0c8c475b9fa"]]},{"id":"c6cca0c8c475b9fa","type":"function","z":"78b25d40d6476ca8","name":"Build header and payload","func":"msg.headers = {}\nmsg.headers['Content-Type']='application/x-www-form-urlencoded';\n\nmsg.payload = {'grant_type':'password', \n               'client_id':'rapt-user',\n               'username':'myUserName',\n               'password':'myAPIpassword'\n              };\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":160,"wires":[["e99a36dddcd7c9e2"]]},{"id":"e99a36dddcd7c9e2","type":"http request","z":"78b25d40d6476ca8","name":"https://id.rapt.io/connect/token","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://id.rapt.io/connect/token","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[x],"x":720,"y":160,"wires":[["710200352bdbbe53"]]},{"id":"710200352bdbbe53","type":"debug","z":"78b25d40d6476ca8","name":"debug 36","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":160,"wires":[]}]

Thanks for your help as I'm stumped.

Here is the cURL that does work that i'm trying to convert into Node-RED
(cleaned)

curl --location 'https://id.rapt.io/connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=rapt-user' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=myUserName' \
--data-urlencode 'password=myAPIpassword'

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

Done thanks

Hi @troyhodges

The debug pane you’re viewing the token in, truncates its output (in code it’s of course not truncated)

You can change these settings in the settings file.

https://nodered.org/docs/user-guide/runtime/settings-file#where-is-my-settings-file

hmm so even if I press the copy value button it still ends in a ..." value when I paste it to notepad. Even when I converted to JSON.
image That seems a bit pointless. I'm yet to get to passing this bearer token back to another API request as have been held up on this value not being complete. I still have my doubts...
Thanks, still investigating

The Nodes and Wires you see, are running server side, and data passing between them will not be truncated, Node RED will be pretty pointless if so.

The debugger pane is a “Preview” into that data, and will be truncated to save your (client side browser) from exploding.

Like i have said, if for some reason you are using the debugger to pass data between different systems yourself, then extend its allowed max chars in the settings file.

If you were to use the token in another HTTP request, in your flow - it will be in its full state. As the debugger pane is a “preview” nothing more.

ok thanks, will continue through the flow tonight. cheers

Thank you it works

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.