POST Request API access token, refresh token, id token

Hi all

I have a problem to keep an API token valid.

The website provides a CURL authorization link which works perfect in the command line of a Raspberry Pi.

curl --request POST --user ‘AAAAA:BBBBB’ --url --header 'Content-Type: application/x-www-form-urlencoded ’ --data grant_type=password --data username=CCCCC --data password=DDDDD

It replies with an access token, a refresh token and an id token.

I already used a POST request node and added in the Request Headers the Header Key “Authorization” with the value “Bearer [access_token]” as a Constant.

It works perfect, but unfortunately, the access_token expires after 86400s (1 day).

I also tried the id_token (Header Key “Authorization” with the value “Bearer [id_token]” as a Constant). It also works, but only for 24 hours.

Therefore I want to integrate the token generation into my Knime Workflow.

The CURL link is like:
curl --request POST --user ‘AAAAA:BBBBB’ --url --header 'Content-Type: application/x-www-form-urlencoded ’ --data grant_type=password --data username=CCCCC --data password=DDDDD

But I have my difficulties to configure the POST request node properly.

I tried:

  • AAAAA:BBBBB → I added this into the Authentication tab under “Basic” → username(AAAAA) & password (BBBBB)
  • Content-Type: application/x-www-form-urlencoded → added under “Request Headers”
  • the “–data” fields (grant_type, username, password) → added under “use constant body” → {“grant_type”:“password”,“username”:“CCCCC”, … }

I have the feeling that the “–user ‘AAAAA:BBBBB’” part is the problem.

I just get “400 - bad request” errors :frowning:

It would be great if somebody has a hint for me.


From the APO specification

curl --request POST
–header ‘Content-Type: application/x-www-form-urlencoded’
–data grant_type=password
–data username=$USER
–data password=$PASSWORD

1 Like

Hi @schanklies

The content type x-www-form-urlencoded is a special one. I had similiar issues but was able to fix this by using the Form Encoded HTTP entity Creator in between.

As such, all the request headers are captures into one. First, I created a component to fill in all the required parameters.


Then encode it (which creates a binary object )

Convert the binary object back to string gives the full request body.

Use that column as body content in the POST request.

Other than that; authentication is none and the Request header is Content-Type: application/x-www-form-urlencoded like you mentioned. This gives me the authentication bearer that I pass as flow variable upstream to other REST nodes.

Hope this helps.


Hi @schanklies @ArjenEX
I was trying to figure out the x-www-form-urlencoded problem within knime.
@ArjenEX’s solution works, but after decoding, I noticed it becomes unnecessary at least in my case

so I went from this:

to this

And it worked too, no need for Form Encoded HTTP entity Creator


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