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

**URL:** <https://discourse.nodered.org/t/how-do-i-provide-username-password-for-kerberos-authentication-in-javascript-to-be-passed-into-an-http-request-node/22275>\
**Category:** General\
**Created:** [26 February 2020 08:29 UTC](https://discourse.nodered.org/t/how-do-i-provide-username-password-for-kerberos-authentication-in-javascript-to-be-passed-into-an-http-request-node/22275 "2020-02-26T08:29:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zainisma](https://avatars.discourse-cdn.com/v4/letter/z/aeb1de/32.png) [@zainisma](https://discourse.nodered.org/u/zainisma)\
**Post date:** [26 February 2020 08:29 UTC](https://discourse.nodered.org/t/how-do-i-provide-username-password-for-kerberos-authentication-in-javascript-to-be-passed-into-an-http-request-node/22275/1 "2020-02-26T08:29:04Z")

</div>

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](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](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](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"  
]  
]  
}  
]

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 April 2020 08:29 UTC](https://discourse.nodered.org/t/how-do-i-provide-username-password-for-kerberos-authentication-in-javascript-to-be-passed-into-an-http-request-node/22275/2 "2020-04-26T08:29:07Z")

</div>

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