1 year ago
#114762

MD SHAYON
Google chrome extension - the main window is closing after getting the code from redirect url
I am trying to develop a login OAuth system in the google chrome extension, notwithstanding, The main window is been disappeared when I attempt to get the response back from the callback.
// background.js
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.message === 'login') {
console.log("Login success - ");
user_signed_in = true;
sendResponse('success');
chrome.identity.launchWebAuthFlow({
// url: `https://discord.com/api/oauth2/authorize?client_id=937186052412678185&permissions=8&redirect_uri=https%3A%2F%2Focdecabdmpigonkcbncodnpgepjjnehm.chromiumapp.org%2F&response_type=code&scope=identify%20email%20guilds%20bot`,
url: DISCORD_URI,
interactive: true
}, function (redirect_uri) {
// console.log("Background - ", redirect_uri);
if (chrome.runtime.lastError || redirect_uri.includes('access_denied')) {
console.log("Could not authenticate.");
sendResponse('fail');
} else {
console.log("Login success - ");
user_signed_in = true;
sendResponse('success');
}
sendResponse('success');
});
/*
*/
return true;
}
});
google-chrome-extension
selenium-chromedriver
google-chrome-devtools
firefox-addon
chrome-extension-manifest-v2
0 Answers
Your Answer