Session auth

If you have a web app and you store the auth token in a cookie, you can make use of it for authentication in your extension.

You can access the cookie in the extension and make authenticated API calls using the same.

Install

Before you add session-auth, ensure you have the initial extension setup. If you have not done that first initialise and then comeback here.

npx ChromeKit-Org/cli add session-auth

When you need to read the cookie, send a message from your content script like this.

let response = await chrome.runtime.sendMessage({
  message: {
    type: "fetch-cookie"
  }
});

console.log(response.cookie);

Note: Ensure to update the right url in host_permissions in manifest.json file and the url in background.js script.

Last updated