Detecting whether user is logged in or not from a Chrome extension

is there an easy way to detect from a Chrome extension that the user is logged into his google account or not.

I guess there is a nasty way to figure this out by loading a html/css/js resource that requires authentication. But i’d like to do this in a “clear” way.

thx and best, Viktor


there has been some discussions on that within the chromium-extensions mailing list:

Basically, as a user suggested, you send an Xml Http Request to, and search through regex, if a current user is signed in:

Source: Guillaume Boudreau (on chromium-extensions mailing list)

var currentUser;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(data) {
       if (xhr.readyState == 4) {
               currentUser = null;
               if (xhr.status == 200) {
                       var re = new RegExp(/<b class="?gb4"?>[s]*([^<][email protected][^<]+)</b>/i);
                       var m = re.exec(xhr.responseText);
                       if (m && m.length == 2) {
                               currentUser = m[1];
               console.log("Currently logged user (on " +
};'GET', '', false);