Access cookies in browser action (chrome extension)?


Access cookies in browser action (chrome extension)?



I have browser_action.html which includes browser_action.js.


browser_action.html


browser_action.js



I'm trying to create an ajax request which includes cookies which are already stored for the domain I'm making a request to (I'm basically piggy backing off the login cookie which is encrypted etc). The user is expected to log into the app separately.



When it sends the ajax though, it's blank when sending cookies.



Thanks



Edit Simply adding it to manifest.json doesnt work.


manifest.json


$.post('http://localhost:3000/dashboard/ext', {
active_tab_url: activeTabUrl
}).done(function(resp) {
...
}).fail(function(jqXHR) {
...
});





Possible duplicate of Send XHR request from Chrome extension with cookies
– wOxxOm
Jul 1 at 4:29





that doesnt fix it
– Tallboy
Jul 1 at 16:50





Without an MCVE I can only keep guessing. Try setting withCredentials in xhrFields. Also try the vanilla XMLHttpRequest.
– wOxxOm
Jul 1 at 16:59


withCredentials





Actually I figured it out... so frustrating. It's because it was really late after doing this like 10 hours. I wasn't noticing the subtleties of not hitting the refresh button after changing the manifest permissions. If you change .js files it updates automatically but it wont refresh the manifest, so my permissions werent getting seen. It boils down to just putting the URL (with a trailing slash) in the permssions area, and then it works without any other changes (no withCredentials etc)
– Tallboy
Jul 1 at 17:04









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Rothschild family

Cinema of Italy