Cookies permission in Chrome extension does not work

I am having a problem with my Chrome extension when I try to add cookie permission. First, the manifest file is similar to this

"permissions": [
    "cookies",
    "https://api.box.com/*", 
    "https://www.box.com/api/*",
    "https://dl.boxcloud.com/*",
    "tabs",
    "identity",
  ],

But when I click on the permission properties of my extension in chrome: // extensions /, the permission does not appear cookies. I'm not sure if this is problematic or not, please help me clarify.

The main problem is when I run the code:

getCookies("https://www.box.com", "tokens", function(tokens){
        console.log("Token returned");     
});

function getCookies(domain, name, callback) {
    console.log("Getting cookies...");
    chrome.cookies.get({"url": domain, "name": name}, function(cookie) {
        if(callback){
            console.log("Done getting cookies, calling back...");                    
            callback(cookie.value);
        }
    });
}

The function is callbacknever called, so the message is Token returnednever printed. I could see the message "Done getting cookies, calling back..in the console. So why is this happening? Please help me solve this ...

+4
1

:

  • cookie , chrome.cookies.get cookie == null.

    , callback(cookie.value) .

  • cookie , URL, , https://www.box.com, "https://www.box.com/api/*". , URL-, , chrome.cookies.get.

+2

Source: https://habr.com/ru/post/1547530/


All Articles