opsb
opsb

Reputation: 30211

How to clear basic authentication (HTTP Basic Auth) credentials in Chrome?

I'm working on a site that uses basic authentication. Using Chrome I've logged in using the basic auth. I now want to remove the basic authentication details from the browser and try a different login.

How do you clear the current basic authentication details when using Chrome?

Upvotes: 501

Views: 327235

Answers (30)

Libin Varghese
Libin Varghese

Reputation: 1734

As mentioned by @SalCelli, chrome://restart works. However, this relaunches all the tabs.

Another method is to launch in incognito mode as suggested by CEGRD

However, if you could not like to restart & use incognito, on Chrome 86 (Mac), I found that the answer provided by @opsb & Mike only works with the below additional steps.

  1. Enter the wrong username in the url without the path

    eg: if the url is http://mywebsite.com/resources/, it will not work if I enter http://[email protected]/resources/, but will work if I enter only http://[email protected]/.

    1. it clears the Basic Auth credentials
    2. prompts for the credentials again
  2. However, entering the valid credentials will not work, as in the background, Chrome still sends the wrong user as part of the url, even though there is correct url in the address bar. When prompted for credentials you need to Cancel, click the address bar and reload the page by pressing Enter. Now enter the correct password.

Upvotes: 7

devnoname120
devnoname120

Reputation: 109

I'm surprised nobody mentioned this but Basic HTTP authentication credentials can actually be deleted from here: chrome://password-manager/passwords

And then you just need to restart your browser to fix it.

I just tested on Windows 11 running Chrome 124.0.6367.78 and I confirm that it works perfectly.

Upvotes: -2

sarkiroka
sarkiroka

Reputation: 1542

Server-Side solution

If you'd like to prompt the user to log out, you can simply send an HTTP header with a 401 status code. Here's how you can do it:

WWW-Authenticate: Basic realm="401"

Optionally, you can include a meta-refresh in the HTTP response body to redirect users back to the main page after logging out:

Authentication required!<meta http-equiv="refresh" content="5; url=/">

(where / is your main page and 5 is 5 seconds delay)

Client-Side solution

To clear the saved Basic Auth credentials, you can send a new AJAX request to the server with the following steps:

  1. Set up an HTTP header for Basic Auth, like so:
xmlHttpRequest.setRequestHeader("Authorization","Basic LTop")

Here, "LTop" is a Base64-encoded string that may contain invalid authentication data. 2. Prepare the URL: take your complete URL, including the protocol, domain, and path, and insert a new authentication part between the protocol and domain. For instance, if your domain is https://yourdomain.com, the prepared URL would be https://-:)@yourdomain.com.

After sending this request, the browser should forget the old credentials, allowing you to refresh the page.

Alternate Solution #1

An alternative approach is to close all of your browser tabs and windows, then reopen the browser. This should trigger the authentication prompt again.

Alternate solution #2

Another option is to use an incognito window. However, this won't work if you've already logged in via an existing incognito window. In that case, close all incognito windows and then open a new one.

Upvotes: -1

Snapey
Snapey

Reputation: 4110

The only thing that worked for me was to add a route to my application that logs the user out and returns a 401 Http error.

In Laravel, this looked like

    Route::get('/clearbasic', function() {
        auth()->logout();
        abort(401);
    });

I can load this route and next access to the regular routes are prompted for the basic credentials.

Upvotes: -1

Craigo
Craigo

Reputation: 3717

From this answer, I worked out I could open Chrome Dev Tools (Ctrl+Shift+I), and paste the following into the console:

{
    const str = location.origin.replace("http://", "http://" + new Date().getTime() + "@");
    let xmlhttp;
    if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest();
    else xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4) location.reload();
    }
    xmlhttp.open("GET",str,true);
    xmlhttp.setRequestHeader("Authorization","Basic YXNkc2E6")
    xmlhttp.send();
}

The page will refresh, and the credentials will be cleared.

Upvotes: 0

Michael Bolli
Michael Bolli

Reputation: 2149

In my case (Win Chrome v100) it worked when using https://@domain.com to delete the credentials. Verify in the dev tools and querying document.URL.

Upvotes: 0

Binh Ho
Binh Ho

Reputation: 4936

This is a quick trick. For example you already input basic auth to url https://example.com by user1:password1. To clear it just open new tab then:

Goto: https://any:[email protected] then your password will be removed.

any:any is any string.

Upvotes: 32

Julien B.
Julien B.

Reputation: 3324

Weirdest thing, but in my case, I was trying to access a page with basic auth and Chrome was sending invalid credentials without even prompting for it. After I logged out from my LastPass plugin, everything was back to normal. So I think LastPass is starting to support Basic Auth but it's not giving the option of what password to use, it looks like it's just sending a random password for a domain that matches (which is very problematic in my case).

Thought it might help someone.

Upvotes: -1

promaty
promaty

Reputation: 197

I was using LastPass password manager, deleting credentials in LastPass solved the issue.

Upvotes: -1

KevinH
KevinH

Reputation: 111

  1. Right click on your Bookmark Bar -> Add Page...
  2. Set the name as Logout Basic Auth
  3. Set the URL as:
javascript: (function() {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            location.reload()
        }
    };
    xmlhttp.open("GET", location.origin, true);
    xmlhttp.setRequestHeader("Authorization", "Basic aW52YWxpZDoK");
    xmlhttp.send();
    return false;
})()
  1. On any webpage you need to logout of Basic Auth, click the bookmark.

Upvotes: 11

Rito
Rito

Reputation: 3290

I am using Chrome Version 83 and this is how I did it. Before following the steps make sure the tab of the site, whose Auth Details you want to delete is closed.

First, go to Settings >> Privacy and security.

enter image description here



Then click on Site settings option
enter image description here



Then click on View permissions and data stored across sites option
enter image description here



Search for the site whose Auth info you want to delete. In this example, I am using Stack Overflow. enter image description here



Now click on the site and then click the Clear data button.
enter image description here



Now restart your browser and you will be asked for a fresh login. For restarting you can type chrome://restart in the address bar.

Upvotes: 8

Shiva Naru
Shiva Naru

Reputation: 1205

For Windows 10: What worked for me was clearing the credentials in the Windows Credentials in the Credential Manager.

Upvotes: 0

Alex
Alex

Reputation: 8483

Just do

https://newUsername:[email protected]

...to override your old credentials.

Upvotes: 7

Richard Hunter
Richard Hunter

Reputation: 2180

I'm using Chrome 75. What I've found is that restarting Chrome doesn't work. But restarting Chrome AND opening the developer tools does work. I don't have any explanation why this should be.

Upvotes: 0

Kundan Atre
Kundan Atre

Reputation: 3961

  1. Press the key combination Ctrl+Shift+Delete
  2. You will see popup in chrome enter image description here

  3. Check the above options and click clear data and you are done.

Upvotes: 0

Bjornicus
Bjornicus

Reputation: 1165

For Chrome 66 I found the relevant option under:

  1. Top right ... menu -> More Tools -> Clear Browsing Data
  2. Click the "Advanced" tab
  3. Check the "Passwords" box (and uncheck others you don't want cleared)
  4. Click "Clear Data"

Using a new Incognito window is probably easier, but for those times you forget and want to clear the saved password, this does the trick without having to restart Chrome (which also works)

Upvotes: -1

TPoschel
TPoschel

Reputation: 3872

This isn't exactly what the question is asking for but in case you accidentally saved basic auth credentials and want to clear them or update them:

https://support.google.com/accounts/answer/6197437

  1. Open Chrome.
  2. At the top right, click More > and then Settings.
  3. At the bottom, click Advanced.
  4. Under "Passwords and forms," click Manage passwords.
  5. Under "Saved Passwords", click Remove on the site you want to clear saved basic auth credentials.

Steps 1-4 can be quickly navigated with this link: chrome://settings/passwords

This worked in Chrome Version 59.0.3071.115

Upvotes: 4

Dave Thompson
Dave Thompson

Reputation: 637

There is no way to do this in Chrome as yet (Chrome 58)

I have found the best solution is to open the url in an Incognito window, which will force you to re-enter the basic authentication credentials.

When you want to change the credentials, close the Incognito window and launch another Incognito window.

Upvotes: 4

Cito
Cito

Reputation: 5593

The authentication is cleared when you exit Chrome.

Note however, that by default Chrome is running apps in the background, so it may not really exit even if you close all Chrome windows. You can either change this behavior under advanced setting, or e.g. under Windows, you can completely exit Chrome by using the Chrome icon in the systray. There should be an icon if Chrome is still running, but maybe you'll find it only in the popup with the hidden icons. The context menu of the Chrome icon has an entry to completely exit Chrome, and you can also change the setting for running apps in the background using that menu.

  1. Open the Chrome menu
  2. Select Settings
  3. Scroll to the bottom
  4. Click Show advanced settings...
  5. Scroll to the bottom
  6. Under System uncheck the box labeled:
    Continue running background apps when Google Chrome is closed

Upvotes: 69

opsb
opsb

Reputation: 30211

It seems chrome will always show you the login prompt if you include a username in the url e.g.

http://[email protected]

This is not a real full solution, see Mike's comment below.

Upvotes: 296

TerryV
TerryV

Reputation: 15

In Chrome, on the right-hand side of the URL bar when you are at a password protected URL, you should see a small key symbol. Click the symbol and it will take you directly to the Password Management area where you can remove the entry. That will ensure you receive future prompts or have an opportunity to enter a new password and save it.

If you do not see the key symbol, that same Password Management area can be accessed by going to Chrome -> Settings -> Passwords and forms -> Manage Passwords. Or more simply, this URL – chrome://settings/passwords.

Upvotes: -1

Sal Celli
Sal Celli

Reputation: 1601

all you need to do is to type chrome://restart in the address bar and chrome, with all its apps that are running in background, will restart and the Auth password cache will be cleaned.

Upvotes: 136

CEGRD
CEGRD

Reputation: 7915

You can open an incognito window Ctrl+Shift+n each time you are doing a test. The incognito window will not remember the username and password the last time you entered.

To use this trick, make sure to close all incognito windows. All incognito windows share the same cache. In other words, you cannot open multiple independent incognito windows. If you login in one of them and open another one, those two are related and you will see that the new window remembers the authentication information from the first window.

Upvotes: 256

John
John

Reputation: 7826

Things changed a lot since the answer was posted. Now you will see a small key symbol on the right hand side of the URL bar.
Click the symbol and it will take you directly to the saved password dialog where you can remove the password.

Successfully tested in Chrome 49

Upvotes: -2

neves
neves

Reputation: 39143

A lot of great suggestions here, I'll give the one that I found the most efficient:

Just change your password in the site. The old authentication will became outdated and Chrome will request it again.

Since I had a terminal open, I did a simple script to change the password and in two keypresses it were incremented.

Upvotes: 0

Montet
Montet

Reputation: 139

Chrome uses the same Internet Options as IE.

Try opening your Internet Options and removing the URL from "Trusted Sites." This should regenerate a 401 call for credentials when you restart the browser and visit the URL again.

You may need to remove it from "Intranet Sites" as well.

Upvotes: -2

Sushovan Mukherjee
Sushovan Mukherjee

Reputation: 604

function logout(url){
    var str = url.replace("http://", "http://" + new Date().getTime() + "@");
    var xmlhttp;
    if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest();
    else xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4) location.reload();
    }
    xmlhttp.open("GET",str,true);
    xmlhttp.setRequestHeader("Authorization","Basic YXNkc2E6")
    xmlhttp.send();
    return false;
}

Upvotes: 26

Ganesh2
Ganesh2

Reputation: 176

May be old thread but thought of adding answer to help others.

I had the same issue with Advanced ReST Client App, I'm not able to clear basic authentication from Chrome neither from app. It simply stopped asking for credentials!

However, I managed to make it work by relaunching Chrome using About Google Chrome -> Relaunch.

Once Chrome is relaunched, when I accessed ReST service, it will ask for user name and password using basic authentication popup.

Hope this helps!

Upvotes: 2

andersjanmyr
andersjanmyr

Reputation: 11540

You can also do it via the settings page, chrome://chrome/settings

  • Under The Hood
  • Advanced Settings
  • Passwords and Forms

Then click the link Manage saved passwords.

Upvotes: -3

Boris Smus
Boris Smus

Reputation: 8472

You should be able to clear your credentials from your browser via "Clear Browsing Data..." in chrome://settings/advanced

Upvotes: -5

Related Questions