How do I provide username/password for Kerberos Authentication in JavaScript to be passed into an HTTP Request node?

Node Red version 1.0.3, node 12.16.0, npm 6.13.4.

I have a problem with authentication access to retrieve data (in JSON format) from a https://webpage located in a pivision server. The authentication method used is Kerberos.

When I use the default authentication fields within http request node (basic, username, password)... I get an error in msg.payload.Message saying "Authorization has been denied for this request."

I have no problem logging in to the same webpage, using the same login credentials into the pop-up window fields, I get when I go to that webpage using Chrome Browser.

I found some resource online recommending the use of node-krb5 ( https://www.npmjs.com/package/node-krb5 ). with the following example provided...

--------- Code Snippet ----------

var krb5 = require('node-krb5');
var REALM=
var username =
var password =

krb5.authenticate(username+'@'+REALM, password, function(err) {
if (err) {
console.log("Error: " + err);
} else {
console.log("OK");
}
});

How do I work this JS snippet into my http request function node, so that I can get authorized by Kerberos to go to that https:\webpage, and retrieve the info I am after?

sample of data returned to chrome after going through Kerberos pop-up authentication process.

{
"Timestamp": "2020-02-25T04:25:53Z",
"Value": {
"Name": "Pt Created",
"Value": 253,
"IsSystem": true
},
"UnitsAbbreviation": "",
"Good": false,
"Questionable": false,
"Substituted": false,
"Annotated": false
}

The link I'm going to looks something like this https:\thewebserver\path1\APIkey\value1

here is my simple flow

[
{
"id": "f5ada93e.7b4b28",
"type": "function",
"z": "aba288aa.04bca8",
"name": "",
"func": "//url: https:///piwebapi/streams//value\n\nvar krb5 = require('node-krb5');\n \n//krb5.authenticate('username@REALM', 'password', function(err) {\nvar my_auth = krb5.authenticate('username@dataservername', 'mypassword', function(err) {\n if (err) {\n console.log("Error: " + err);\n } else {\n console.log("OK");\n }\n});\n\nmsg.url = "https://thedataservername/piwebapi/path1/webIDtoken/value";\nmsg.method = "GET";\nmsg.headers = {\n \n Authorization : my_auth\n };\nreturn msg;\n\n",
"outputs": 1,
"noerr": 0,
"x": 310,
"y": 880,
"wires": [
[
"e349fa3a.f7d578"
]
]
},
{
"id": "e349fa3a.f7d578",
"type": "http request",
"z": "aba288aa.04bca8",
"name": "",
"method": "use",
"ret": "obj",
"paytoqs": false,
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "basic",
"x": 470,
"y": 880,
"wires": [
[
"b32d074b.df90f8"
]
]
},
{
"id": "b32d074b.df90f8",
"type": "debug",
"z": "aba288aa.04bca8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 630,
"y": 880,
"wires":
},
{
"id": "32187ec5.c73ed2",
"type": "inject",
"z": "aba288aa.04bca8",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 160,
"y": 880,
"wires": [
[
"f5ada93e.7b4b28"
]
]
}
]

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