How to use basic default authorization dialog in browser in angular2
I am getting the above error (401 unauthorized) when making a http post request to the server. I find many online sources suggesting to intercept these and make my own login interface, but I would like to use the default browser login interface for basic auth.
How to trigger the browser default base archive popup dialog when getting an unauthorized 401 status in angular2 instead of logging it as an error?
+3
source to share
1 answer
Same problem here. Working chrome with:
var xhttp=new XMLHttpRequest();
xhttp.withCredentials = true;
xhttp.open("GET", "https://httpbin.org/basic-auth/user/passwd", true);
xhttp.send();
Use "user" and "passwd" as credentials for this endpoint. Don't know your code, but exceptions show XMLHttpRequest. so withCredentials should do the job
0
source to share