This folder contains a sample Chromium extension demonstrating how to integrate OIDC library, with a workaround for chromium manifest v3.
key points:
- runs inside the extension service worker (former background page). Inside the service worker it:
- mocks global window object with JSDOM
- mocks global localStorage and sessionStorage API and maps it synchronously to the chrome.storage API
- exposes global function signIn() and signOut() and getSignedInUser()
- Create a new app registration in the Azure Portal.
- Provide your client ID in the
PublicClientApplication
configuration inauth.js
. - Under the Authentication tab, add a new redirect URI under Single-page application.
- The url of this redirect URI should be of the format
https://<extension-id>.chromiumapp.org
, e.g.https://epfnbngoodhmbeepjlcohfacgnbhbhah.chromiumapp.org/
. - You should also set this url as the Logout URL.
- Your extension ID can be found on the Extensions settings page after the extension has been loaded, or by invoking
chrome.identity.getRedirectURL()
in the extension.
- On the Extensions settings page, click the Load unpacked button, and select this folder.
- The extension will appear in the browser toolbar.
- Note: Because this extension relies on the
chrome.identity
APIs, it will not work in incognito/private browsing. - The extension demonstrates how to login, acquire tokens, and logout using OIDC-client-ts library.