Convertigo Public Knowledge base
How to set up a Basic Authentication with the HTTP Connector?
The HTTP connector has properties to perform multiple Authentications to a REST API.
For a βBasic' authentication change the βAuthentication typeβ property from βNoneβ to 'Basicβ.
Then use βBasic/NTLM authentication user' and 'Basic/NTLM authentication passwordβ properties to set the authentication credentials:
Β
Sometimes, this way of proceeding is not enough to take more control on dynamic values.
So, there are alternatives you can use to perform dynamic Basic Authentication:
#1 Modify onTransactionStarted() handler to add the Authorization header in the HTTP transaction
Add the transaction started handler in your HTTP transaction:
Β
Double-click the transaction and add the following to the onTransactionStarted() function:
var auth_header = 'Basic ' + com.twinsoft.convertigo.engine.util.Base64.encodeString(tr_basic_user + ':' + tr_basic_password);
var header = new com.twinsoft.convertigo.beans.common.XMLVector();
header.add('Authorization');
header.add('mytoken');
context.connector.httpParameters.add(header);tr_basic_user and tr_basic_passwordare the transaction variables that hold the credentials.
Output example:
Β
#2 Use a sequence to generate the Authorization header and use Convertigo internal engine variable __header_XXX
Leave the βAuthentication type' HTTP Connector property to 'Noneβ
Use the '__header_Authorization' variable in your transaction
In the sequence, you can generate the Basic Authorization value with a jElement Step and the following βExpressionβ property:
'Basic ' + com.twinsoft.convertigo.engine.util.Base64.encodeString(basic_user + ':' + basic_password);In your Call_transaction Step, Source the __header_Authorization variable with the jElement Step value:
Β
Output example:
Β
