SpiouneS
Convex Community4mo ago
3 replies
Spioune

Chrome Extension Auth

Hi guys,
I have a chrome extension that is injected into a website and I have my main web application.
Users can login to the main application with Google (using Convex Auth https://labs.convex.dev/auth)
I am trying to share auth tokens with my extension.
When users click "Login" on the extension, I open the main app in another tab, they sign in with google, I use window.sendMessage to send the token to the extension background script and get the token on the extension.
Now that I have the token, I cannot get convex on the extension to authenticate.
I tried client.setAuth(FetcherFunction, onChange). OnChange callback returns isAuthenticated=true but my react app is not rerendering and if I refresh the page the token is gone.
I also tried sending the JWT+Refresh token from the web app localstorage to my extension storage. This works but I need to hard refresh the page to get my react app to rerender and force convex to get the tokens from extension storage.

Any idea why client.setAuth(FetcherFunction, onChange) doesn't save token to storage and rerender my react app?
How can I authenticate the 2nd convex app using the 1st convex app jwt token (without having to hard refresh the page)?
Was this page helpful?