I want to display a google login page as soon as i fire up my extension where the user will login to his google account.
I was able to display details of the currently logged in user by following instructions from chrome.identity User Authentication in a Chrome Extension
My background.js has the following code
chrome.identity.getAuthToken({
interactive: true
}, function(token) {
if (chrome.runtime.lastError) {
alert(chrome.runtime.lastError.message);
return;
}
var x = new XMLHttpRequest();
x.open('GET', 'https://www.googleapis.com/userinfo/v2/me?alt=json&access_token=' + token);
x.onload = function() {
alert(x.response);
};
x.send();
});
However, I want to be able to login to my extension using a different google account than the one which is logged in currently to chrome. How do I do this?