How to set http header 'www-authenticate' for proxy authentication in .js

907 Views Asked by At

I am getting error: http header 'www-authenticate' used for proxy authentication not found, while running .js script. I have tried many ways to set proxy authentication but it's giving syntax error everytime. Following is my code and commented lines are the ones that I have tried (but not working):

var url = someURL; var result;

var request = new HttpClientRequest(url);
//request.header("Authorization", "Bearer token")
//WWW-Authenticate: Bearer token
request.method="GET";
//request.header('WWW-Authenticate: Bearer token realm="My Realm"');
request.header["Content-Type"] = "text/xml; charset=utf-8";
//request.header["WWW-Authenticate"] = "Bearer token";
1

There are 1 best solutions below

0
Barkha On

I figured out the answer. Authentication header can be set as follows: request.header["Authorization"] = "Bearer token";