Its because the client_id doesnt match the extension id. The error only happens in a extension loaded manually (it has different id than the store one). Solution: create a second clientid in the dev console, pointing to your local extension. Use that one while developing. Switch it back before publishing (very important!)
keep getting kicked out my google login when using chrome.identity api
-
12-07-2023 - |
문제
I'm creating a chrome extension, I want to connect it with google spreadsheet to modify and load sheets. When I using chrome.identity API to get auth, my session of google account in Chrome always been kick out. even when I using sample code from the google.
here is some code of my extension(only paste the core code): manifest:
"permissions": [ "*://*/*",
"storage",
"tabs",
"contextMenus",
"alarms",
"identity"],
"oauth2": {
"client_id": "64262386828-sng3chvgvldosl1586trtngrcp7ocfv5.apps.googleusercontent.com",
"scopes": [
"https://spreadsheets.google.com/feeds",
"https://docs.google.com/feeds",
"https://www.googleapis.com/auth/plus.login"
]
},
"browser_action": {
"default_popup": "popup.html"
}
popup.js:
var ci = chrome.identity;
$(document).ready(function () { $("#getAuth").click(function () { getAuth(); });
function getAuth() {
var access_token;
var retry = true;
getToken();
function getToken() {
ci.getAuthToken({ interactive: true }, function(token) {
if (chrome.runtime.lastError) {
console.log(chrome.runtime.lastError);
return;
}
access_token = token;
});
}
}
});
Here is a short video to show this problem: http://screencast.com/t/yiKYJUBv and also, it only kicks me out from chrome, I can still access Gmail or something else.
해결책
제휴하지 않습니다 StackOverflow