How do I log out with HTTP Basic?
Solution 1:
For most browsers
Log in with a nonsense user using the address bar. For example, if you logged on to http://codereview.internal.company and loaded the URL http://codereview.internal.company/r144
, enter this:
http://logout:[email protected]/r144
h/t Riyadi on tolaris.com
For Chrome
This used to worked on Chrome, but no longer. There might not be a complete solution, but see https://superuser.com/a/1598511/28585 and https://stackoverflow.com/a/64611309/327615 for some discussion.
Solution 2:
For chrome browser you can restart the chrome application completely by typing in the address bar.
chrome://restart
Another way is that, always open the browser in incognito mode. For chrome the shortcut is
ctrl + shift + n
Another way you can try it out is that, try to give wrong credentials if you want to logout. Say,
randometxt@localhost:3000
*sometimes, this works.
Solution 3:
From the answer
You have the following options on Chrome
-
chrome://restart
-
Launch in incognito mode
-
Enter the wrong username in the url without the resources
eg: if the url is
http://mywebsite.com/resources/
, it will not work if I enterhttp://[email protected]/resources/
, but will work if I enter onlyhttp://[email protected]/
- it clears the Basic Auth credentials
- prompt for the credentials again
-
However, entering the valid credentials will not work, as in the background, chrome still send the wrong user as part of the url, even though the url appears right in the address bar When prompted for credentials you would need to
Cancel
, and click the address bar and reload the page from pressingenter
. Now enter the correct password