http basic authentication “log out”

前端 未结 8 1352
悲&欢浪女
悲&欢浪女 2020-11-28 04:23

HTTP basic authentication credentials are stored until the browser is closed, but is there a way to remove the credentials before the browser is closed?

I read about

8条回答
  •  醉话见心
    2020-11-28 04:33

    This codes worked for me in Chrome (version 83):

    var xhttp = new XMLHttpRequest(); 
    xhttp.open("GET", "/url_that_return_401", true); 
    xhttp.setRequestHeader('Authorization', 'Basic '); 
    xhttp.send();
    

    Need to execute this code (maybe by button click or console window) and then prompt appeared, you need to press Cancel button. Then authentication fields clears and you can refresh page and login in with another credentials.

提交回复
热议问题