react-oauth
react-oauth copied to clipboard
Next js application on production is giving error of popup closed after selecting gmail account from popup.
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!
Hi @ArslanYounis are you able to fix this issue? I'm facing the same problem.
@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 I'm facing the same problem. I'm just run the app in the local
@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 make sure you whitelisted your staging domain in google console