react-oauth icon indicating copy to clipboard operation
react-oauth copied to clipboard

Next js application on production is giving error of popup closed after selecting gmail account from popup.

Open ArslanYounis opened this issue 1 year ago • 5 comments

Hi, Here is my code for useGoogleLogin. const loginWithGmail = useGoogleLogin({ onSuccess: async (tokenResponse) => { try { await googleLogin(tokenResponse?.access_token); if (isMounted()) { const returnUrl = "/dashboard"; router.push(returnUrl).catch(console.error); } toast.success("You're Logged in successfully!"); setGoogleLoading(false); } catch (error) { setGoogleLoading(false); toast.error(error?.response?.data?.message); } }, onError: (errorResponse) => { setGoogleLoading(false); toast.error( typeof errorResponse === "string" ? errorResponse : errorResponse?.error_description ?? "" ); }, onNonOAuthError: (errorResponse) => { setGoogleLoading(false); }, }); It's working absolutely fine on localhost. but while I try to log in on to production it's giving this error after selecting a Gmail account from popup. message : "Popup window closed" stack : "Error: Popup window closed\n at new $o (https://accounts.google.com/gsi/client:224:388)\n at jq.B (https://accounts.google.com/gsi/client:273:198)\n at pc (https://accounts.google.com/gsi/client:61:465)\n at _.l.dispatchEvent (https://accounts.google.com/gsi/client:60:347)\n at _.Ue.D (https://accounts.google.com/gsi/client:129:179)" type : "popup_closed". Application is build with next js and is hosted on vercel.

Thanks in advance!

ArslanYounis avatar Apr 05 '23 16:04 ArslanYounis

Hi @ArslanYounis are you able to fix this issue? I'm facing the same problem.

wesleyguirra avatar May 09 '23 13:05 wesleyguirra

@wesleyguirra In my case it was actually an issue in the configuration of apiKey for production. I recreated that apiKey and it started working fine.

ArslanYounis avatar May 09 '23 14:05 ArslanYounis

@ArslanYounis I'm facing the same problem. I'm just run the app in the local

zhaoyunyi avatar May 10 '23 07:05 zhaoyunyi

@ArslanYounis When you say "apiKey" do you mean the clientId? I'm currently facing this issue, although I'm using React with Vite. I've double checked the clientId on our staging environment is set correctly and it's set exactly the same as local.

The only difference is that locally it seems to work fine.

db-qc avatar Jul 05 '23 15:07 db-qc

@db-qc make sure you whitelisted your staging domain in google console

MomenSherif avatar Jul 06 '23 07:07 MomenSherif