Create new credentials flow variable

Hi Community,

I would like to create a new credentials flow variable from my node.
Currently I just do:
pushFlowVariableString(“User”, userName);
pushFlowVariableString(“Password”, password);

is there something like pushCredentialsFlowVariable or can I somehow turn these string flow variables to a credential?

I tried to check out:

but could not quite grasp what do to… :see_no_evil:
Is there a simple way to create new credential variables?

Thanks in advance (and sorry if i missed something obvious)

Hi @AnotherFraudUser,

You have two options, you can either use this method

This would be the easiest method, but it is not encouraged. Instead, you can use the auth pannel created for the new filehandling framework, you can take a look at e.g. FtpConnectorNodeDialog from the org.knime.ext.ftp.filehandling plugin. The sources for that plugin are not published to github yet but you access them as described in this post:

best,
Gabriel

2 Likes

Hi @gab1one ,

i fail to get any of the two versions to work.
For the “auth pannel” version - I followed the steps in the post but cannot find org.knime.ext.ftp.filehandling in the “Open Type” explorer (I tried with release 2020-12 as well as with 2019-12)
Not sure which version it should be in?

For the “newCredentialsFlowVariable” how would I call this function? I do not seem to have any access to the credentialsstore from my NodeModel level.
I would need a WorkflowManager reference to create a new instance (which i also do not see where to get)
The the getCredentialsProvider() is availible - which does not help in getting either one :frowning:

Not sure if I miss anything…

Which target platform do you have set? You need to use KNIME-AP-complete.target to make sure you get all plugins.

That is a static method on the CredentialsStore class, you can use it as follows:

        FlowVariable flowVar =   CredentialsStore.newCredentialsFlowVariable("credential_name", username, password, false, false));

And then you can push it like you do with any other variable.

best,
Gabriel

Hi @gab1one,

I did the following steps:

  1. Change to 2020-12 release (as well as 2019-12)
    grafik

  2. Use KNIME-AP-complete.target
    grafik

  3. Reload and reload target platform

4.Add All Plug-ins

After these steps I open “Open Type”
grafik

grafik

Hi @gab1one,

yes this looks great! :slight_smile:
But here I am not quite sure how to push it.
Normally I just use

   pushFlowVariableString(name, value);
   pushFlowVariableDouble(name, value);
   pushFlowVariableInt(name, value);

But for credentials I guess I have to use the generic one?
But
pushFlowVariable(flowVar); //is not visible
pushFlowVariable(“PWD”, flowVar.getVariableType(), flowVar.getValue(VariableType.CredentialsType)); //not quite sure how to get the flowVariable here :frowning:

Sorry for all these questions - but regarding flow variable usage - it seems like there is little information to look into :see_no_evil:

As we found out in our call, you can use

import org.knime.core.Node;
... 

Node.invokePushFlowVariable(this, value);

These methods are not public API and so they could change at any time in the future.
Using the DialogComponents is a better idea.

best,
Gabriel

1 Like

Hi @gab1one,

thanks for the solution!
I works great! :+1:

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