window undefined on background script when trying to login via firebase
I'm using React + Firebase.
I have a hook that handles user details and a background script that handles the auth via
chrome.identity.getAuthToken
after I approve the consent screen, the background script throws "window is not defined" any ideas?
I followed this link - https://www.plasmo.com/blog/posts/firebase-chrome-extensionFirebase Authentication with React in an MV3 Chrome Extension
Diving deep into everything you need to make Firebase Auth work with your MV3 Chrome Extension
9 Replies
It uses `sighInWithCredential, and inside it tries to work with local storage on window.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Ye, I'm trying to authenticate using firebase
@ar7casper has reached level 1. GG!
In your example, you use a popup, which is nice and all.
In my case, I work with a content script.
So, I don't have
chrome.identity
, so I need to use a background script.
Then, when I use that, it fails on window.Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
@generic has reached level 1. GG!
@ar7casper have you managed to make use of window in it?
The background script is essentially a service worker. It doesn't has any idea about the DOM related stuff.
Think of it as a separate server.
You need to use sendMessage.
That's in general.
Regarding Plasmo, haven't tried it yet, will do soon and can report back.
Assuming nothing much different there.