Using flow variables for tokens in GET requests does not work in New Dialog

Hallo,

What it’s about: For a project, I need to read data from sensors via a REST interface and store it in a database. To do this, I have to use a token for n users, which I have to determine. This token must then be used later for the GET request nodes.

The token is determined using the Python node and stored in a flow variable.

I use a loop to create the URL for the GET request for a specific period of time.

The URL and token are then used by the GET request.

It is very important that this works 100%. The created worksheet must ultimately run in specific cycles. The token is occasionally renewed by the provider.

I’m absolutely certain that I managed to do it in the old dialog. Unfortunately, I no longer have a screenshot of the old dialog. It was this dialog

I’ve been working on the worksheet for weeks now, and yesterday I spent two hours trying to figure out why some GET requests work and some don’t. There was a new token. So I could continue working, I manually inserted the new token everywhere.

The new dialog is now also available for GET requests. Here, using the flow variable for the token doesn’t work for me.

It works with the flow variable for the URL.

Credentials:

Token inserted manually here. I can also select the flow variable manually. If I do this, the Credentials field cannot be changed. However, this has no effect; the token is not taken from the flow variable. Even if I leave the field blank.

When I use variables and select my flow variable with the token, something is transferred to the Credentials variable, but it doesn’t work.

Am I doing something wrong?

This functionality is essential for a scientific university project. The worksheet should run automatically in two weeks.

If it is a bug, how quickly can it be fixed?

Best regards

Patrik

Hi @PatrikS

I could not really follow how you create this credential variable in python. In general, even if it has the new UI, the node works 1:1 like in the classic UI. If we introduce breaking changes, you will notice the old node gets (deprecated) added to the node name and there will be a new node with exacly the same name.

But the MISSING indicates that
a) the variable is not there anymore OR
b) there might be a session timeout after you have set the variable (e.g. If a Google session expires and the list of Google Sheets can no longer be retrieved, a previously configured selection of the sheet to be read will be shown as MISSING. You then need to rerun the session)

1 Like

Hello,

Here’s how I create the token:

Everything works with this setting. I think I copied the “Tocken” part here.

If the provider changes the token, nothing will work anymore. This happened at the office.

If I change it as follows, “missing” and the token appear. I copied the entry and it matches the created token.

GET Request

Execute failed: No credentials stored to name “ …And the token is displayed here…..

Hallo,

Okay, I’ve looked at everything again.

The fact is, I can select a flow variable manually. However, this isn’t supported.

Why?

It only works if I copy the token into the input field. That’s it.

If I select “Variable” and then the flow variable, the error occurs as described.

The fact that the flow variable isn’t used manually only came to light because the provider changed the token. I was initially told it would never change for a customer. But apparently, that’s not the case.

I then searched through the examples and found the following approach, which also doesn’t work.

The actual worksheet was developed over the last few weeks, and there have never been any timeouts or other problems. Hundreds of GET requests are made every day.

The workflow is now set up, and it’s crucial that it continues to run even if the token changes.

So, how do I achieve this?

For manual implementation, I need to be able to use a flow variable.

Regards,
Patrik

Hi Patrick,

It seems to me that you are trying to use a flow variable of StringType as bearer token input. But this was never supported, you need to create a credentials flow variable for your token.

When we migrated this node to the modern UI dialogs we missed to remove the flow variable control icon from the “Token“ text input field and from the credentials dropdown which makes it confusing to use.

So you need to use the “Variable to Credentials“ node to first create a credentials flow variable for your token, then choose “Bearer Token“ as authentication method, select “Variable“ credentials type and use the dropdown to select you credentials flow variable.

Hope that helps

Magnus

3 Likes

Hi Magnus,

Sorry for the late reply. No, unfortunately that doesn’t help. As I mentioned, I retrieve the token using a Python script. I derived this from the API documentation (JavaScript). I store the returned token in a table and in a flow variable for later use. As you can see, it’s a string.

https://observablehq.com/@57ac0233e9966902/api-workflow-for-users?collection=@57ac0233e9966902/sencrop-api-documentation

I can also copy and paste this from here into Credentials / Manual, and everything works.

I had no other choice. Since it’s a string due to the return type, why does it work even though you say it shouldn’t?

It would be a real bummer if it didn’t. But it doesn’t really matter whether I copy the token here or pass it via a flow variable.

I didn’t know about “Variable to Credentials”; otherwise, I would have given up much sooner.

This isn’t helping either:

“OAuth2 Authenticator (Client Credentials)”

“OAuth2 Authenticator (Password)”

OAuth2 Authenticator (Client Credentials) Execute failed: Could not retrieve access token (HTTP 400 - Bad Request)

OAuth2 Authenticator (Password) Execute failed: Could not retrieve access token (HTTP 400 - Bad Request)

So now the question is: what do I need to do to make “Variable to Credentials” work?

And how do I get the token?

It’s frustrating—why make it complicated when it could actually be so simple? I can already see myself having to replace the GET request nodes with Python scripts.

Unfortunately, I’m not familiar with REST either—are there parameters missing or something?

Best regards,

Patrik

@PatrikS After converting your token from a string to a credential with the Variable to Credentials. In the GET Request node, try selecting it directly in the “Credential variable” dropdown instead of using the flow variable icon at the top right.

Highlighted in green above.

Hallo K10shetty1

Sorry, I just don’t get it. I already have my token. How am I supposed to use “Variable to Credentials” to convert a string into login credentials? Last try as I understand it, that’s what you mean.

When I think about how many hours I’ve spent tinkering with this, I can only shake my head. That was my last attempt. No one can understand this.

But it only works if you add the Get Request node again. If you’ve already manually copied the token in, you won’t see the selection described by K10shetty1.

I hope so. I’ll try adjusting a worksheet accordingly.

Thank you so much for the tip, K10shetty1

Patrik

@PatrikS From the above images I can see that your token is stored in a string flow variable named test_token, after the variable to credentials node this is converted into a credential flow variable named Credentials. Now use this credentials flow variable in the Get request node (cred in my previous screenshot).

That’s not true.
Just to point out that it was and still is entirely possible to use a string variable.
As of LTS 5.8.2 it is still working like this (same with Bearer); and yes, due to poor UX, I am still using the classic UI.
The option of credentials, also with Tokens, is kind of new (introduced in some 5.X Version?), but before that the only way to use tokens in Requests was via a flow variable.

@PatrikS , have you tried configuring the node within the classic UI?

Hi @tgoedeke

You are referring to a separate thing. I meant (maybe not clear enough) that it was not possible to use StringType flow variable input in the “Authentication” tab before. But yes this can be an alternative to use it (also in modern UI via “Constant” kind request headers) thanks for suggesting it.

before credentials even existed, that was possible, too - but that was quite a while ago :wink:

1 Like

Hallo,

Sorry for getting back to you so late. I had to adjust all the GetRequest nodes, and the API threw up a few more problems for me as well.

I’ve been using the new UI for a while now and don’t plan on switching back to the old one. It’s caused me enough headaches in the past.

But everything is working now.

What remains, well… The way I’m doing it now isn’t very intuitive. I’m using a form where I would normally enter my login credentials to get the token. But instead, I enter the token I already have to generate a variable that I then use in GetRequest. You really have to figure that out on your own.

On the other hand, in GetRequest under “Manual,” you can also paste the token from an editor, and it works. In my opinion, this is poor programming—and not just in this instance.

Thanks again

Best regards

Patrik