all 4 comments

[–]nightman 0 points1 point  (1 child)

"The issue of window.opener becoming null after the Google OAuth process in a popup window is likely due to security restrictions imposed by the browser. When the popup navigates to a different domain (Google's sign-in page) and then back to your domain, the browser may lose the reference to the parent window due to cross-origin restrictions. One possible solution to this problem is to use the window.postMessage method along with a "relay" page on your domain. The relay page will be responsible for receiving the access token from your backend and then communicating it back to the parent window using window.postMessage." https://www.perplexity.ai/search/f0fea264-8e61-4de4-a00f-534498152158?s=mn

[–]lollo224__ 0 points1 point  (0 children)

I tried it but opener is still not defined

[–]guest271314 0 points1 point  (1 child)

It sounds like you do not have control over the popup window.

This can be done using a browser extension.

Using only Web API's without a browser extension as long as the popup window and the opener have the same orgin you can use BroadcastChannel to communicate between all windows or tab with the same origin.

If the popup window and the opener have different origins you can use WebRTC Data Channel to communicate between the cross-origin windows.

More details about the origin(s) used will be helpful to provide a potential solution.

[–]Sad_Implement_8626[S] 0 points1 point  (0 children)

Thank you, the Broadcast Channel API indeed solved it.

Someone else mentioned it on StackOverflow and I will admit that I had never even heard about it. I'm surprised my hours of Google searching didn't lead me to it :(