Hi there,
I want to build a custom Python based KNIME Extension Node with a password parameter input.
So basically a string input with hidden user input on the visual interface (html would be <input type="password">
). Nothing special and should be implemented with a single line of code.
But it’s unfortunately missing and I can’t expend the python knime library…
Please help
Hi @mkammerer,
Indeed, we currently don’t have a password input field in Python nodes. One reason for that is that everything the user inputs in these fields is currently stored in plain text XML files inside the workflow.
The KNIME-way of doing this right now is to use a Credential Configuration to let the user input username & password, feed this as flow variable into your Python node and then have a drop down in the Python node that offers the user to choose one of the connected credentials. The username and password can then be accessed by the get_credentials
method of the ConfigurationContext
or ExecutionContext
inside your Python node (see the API docs).
Roughly like this:
@knext.node(...)
class MyNode:
credential_param = knext.StringParameter(label="Credential parameter",
description="Choose one of the connected credentials",
choices=lambda a: knext.DialogCreationContext.get_credential_names(a))
def configure(self, ctx: knext.ConfigurationContext):
if not ctx.get_credential_names():
raise knext.InvalidParametersError("No credentials provided.")
if not self.credentials_param:
raise knext.InvalidParametersError("Credentials not selected.")
...
def execute(self, ctx: knext.ExecutionContext):
credential = ctx.get_credentials(self.credentials_param)
login( credential.username, credential.password)
...
Wow, thank you for the quick reply! I’ll try it!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.