How to get Credential from credentialSpec

Hi,

I’m working on a custom node in Java and in that node I’ll need to get an AccessToken from another node (Microsoft Authenticator).
I already have create my custom node and managed to a build it with two input ports (one for the BufferedDataTable and one for the credentials CredentialPortObject).
Here is where I’m stuck, in my execute function I can get the CredentialPortObject but I don’t know how to get the AccessToken (should be a JWToken stored as a password) from that object.
protected BufferedDataTable execute(PortObject inData, final ExecutionContext exec)
throws Exception {
/*
* The input data table to work with. The “inData” array will contain as many
* input tables as specified in the constructor. In this case it can only be one
* (see constructor).
*/
BufferedDataTable inputTable = (BufferedDataTable) inData[DATATABLE_PORT];
DataTableSpec spec = inputTable.getDataTableSpec();

	// get the access token from the credential port
	CredentialPortObject credentialPortObject  = (CredentialPortObject) inData[CREDENTIAL_PORT];
            ...

	return new BufferedDataTable[] { out };
}

NB this AccessToken will be required both at configuration and execution time

Hi @didierbastogne,

this is how the Sharepoint Connector node does it: knime-office365/org.knime.ext.sharepoint.filehandling/src/org/knime/ext/sharepoint/filehandling/node/SharepointConnectionNodeModel.java at 412f0366a93626758a69c075f6fdbb4bc3635aaa · knime/knime-office365 · GitHub

Since you get if from the spec, it’s also available at configure time.

Hope it helps!

2 Likes

Hi Manuel,

thanks a lot, this is exactly what I was looking for!

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