anthonyjgrove / react-google-login

A React Google Login Component
https://anthonyjgrove.github.io/react-google-login
MIT License
1.84k stars 427 forks source link

Error "popup_closed_by_user" #132

Open dukeace2005 opened 6 years ago

dukeace2005 commented 6 years ago

Getting 'popup closed by user' error after choosing Google account and clicking 'Allow' in popup screen. Here is my request: <GoogleLogin clientId='.....apps.googleusercontent.com' buttonText="Login" scope='https://www.googleapis.com/auth/drive.file' onSuccess={this.responseGoogle} onFailure={this.responseErrorGoogle}/>

Kinertia commented 6 years ago

+1 for this issue. Everything appears to work, but not getting anything in the response and seeing this error in the console.

mathurs commented 6 years ago

This is likely because your google + api is not enabled. Go to Library and search for plus api. There should be a result for google plus API, please enable it and try again.

alexghi commented 6 years ago

Any news on this?

dougneves commented 6 years ago

I was experiencing the same problem here. It was resolved when I re-created google credentials.

Go to https://console.developers.google.com/apis, and in the Google Plus API, access credentials, and create a new credential for "Oauth Client Id". In the "Application Type" select "Web Application". Be sure to put the full address of where the API is being called in the "Authorized redirect URIs". Finally, use the new "Client ID" that will be generated.

Despite this, the message displayed ("popup_closed_by_user") is not correct, so I believe the issue should be kept open.

tirli commented 6 years ago

Also getting this error. And seems like it's random and based on loading status. Because sometimes when I wait enough, I'm not getting an error. What is more, after I added this button, sometimes I'm getting infinite loading after reload (and in this state, the button always returns popup closed by user)

glorp47 commented 6 years ago

+1 this issue just started occurring for me...

g33ktony commented 6 years ago

Also happening to me

m1m1s1ku commented 6 years ago

Same for me

braco commented 6 years ago

Try clearing your browser cache

tirli commented 6 years ago

Clearing cache can help for a while, though the main problem is that error description doesn't explain what happened. And it's what should be fixed.

dylankilkenny commented 6 years ago

Having the same issue. It works normally in chrome, but getting { error: "popup_closed_by_user" } in firefox

xoapit commented 6 years ago

Clear browser cache and open new tab. It works for me.

grugna commented 6 years ago

I have the same issue in chrome only. It works in Firefox and Safari

prodislav commented 6 years ago

its help me: https://github.com/anthonyjgrove/react-google-login/issues/132#issuecomment-364713349

Drnutsu commented 6 years ago

how about this issues ?

khalidahmada commented 5 years ago

Clear cache and refresh will work. It work for me.

Sunny-Lau commented 5 years ago

Got this error on local, fixed it by including port number in the 'Authorized JavaScript origins', which is http://localhost:8000 instead of http://localhost

subash-poudel commented 5 years ago

I fixed this issue by whitelisting

http://localhost

and adding cookiePolicy

<GoogleLogin clientId={WEB_CLIENT_ID} buttonText="Login with LF account" onSuccess={this.responseGoogle} onFailure={this.responseGoogle} cookiePolicy={'single_host_origin'} />

https://developers.google.com/identity/sign-in/web/reference#googleauththenoninit-onerror

danmo commented 5 years ago

2019, the issue is still present. Hit me out of nowhere.

benjaminadk commented 5 years ago

Clearing the cache worked for me as well.

thiagonache commented 5 years ago

for me, every time you have this error is because something is miss-configured, google or code.

vemarav commented 5 years ago

worked after clearing browser cache and cookies

retzion commented 5 years ago

I have a website deployed that serves a number of domains. All my .com domains on this hosted site work fine but my .dev site simply will not work unless I use an incognito browser. I can even open a new computer and visit the site for the very first time and I get an error. (All browsers) Response from the iframe request : {"valid":false} Does anyone have any insight as to why?

junlee91 commented 5 years ago

Response from the iframe request : {"valid":false} Does anyone have any insight as to why?

@retzion Configure your Authorized JS origin & redirect URI as mentioned in https://stackoverflow.com/a/53510968/8254487

Curti-s commented 5 years ago

Just cleared 1.3gb of cookies and cache but still no gain. Each time I try to sign up I get invalid client, right after setting http://localhost:3000 in google credentials

narthur commented 5 years ago

Clearing the cache doesn't strike me as a good solution if you're trying to make sure your users aren't hit with this error.

This solution worked for me: https://github.com/anthonyjgrove/react-google-login/issues/132#issuecomment-458029717

ahmedrafayat commented 4 years ago

This is how I got it to work in Chrome, Go to Setting -> Advanced -> Clear browsing data -> Cached images and files -> Clear Data Also try this, going to site settings and make sure you allow 'Popups and redirects'

karel947 commented 4 years ago

09/2019 Still facing this issue, quite sad...

Edward101701 commented 4 years ago

My colleagues on Mac and Windows face this problem as well. But on Mac more frequently

ap0ca commented 4 years ago

Check your browser plugins... Disable some which could potentially block trackers. In my case it was Privacy Badger

koynu14 commented 4 years ago

any updates regarding on the issue?

JoshuaVSherman commented 4 years ago

no because you need the hash string as well to decode the jwt token, and your server-side code using the GoogleClientSecret

here is my working example: https://github.com/WebJamApps/web-jam-back/blob/dev/auth/google.js

On Fri, Jul 17, 2020 at 8:42 AM AminRafaey notifications@github.com wrote:

Hello everyone, Using OAuth 2.0 Client ID directly in the client-side will not expose our credentials? Anyone can go into the console of browser and after getting this id can use it for getting data from google on our behalf

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/anthonyjgrove/react-google-login/issues/132#issuecomment-660085330, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFY3WB3F7WPXVAYIUVL3LLR4BBKLANCNFSM4EGE3MKQ .

-- Josh Sherman https://web-jam.com https://www.linkedin.com/in/joshuavsherman/ 540-494-8035

alozytskyi commented 4 years ago

Check your browser plugins... Disable some which could potentially block trackers. In my case it was Privacy Badger

Thanks! Unlocking google domains in privacy badger has helped me.

cambo2015 commented 3 years ago

I fixed the issue in my chromium-browser. I tried to clear my cache, but no change. The issue for me seemed to be that third parties cookies are not allowed. I am using localhost:3000/8000, client/server. chromium>settings>privacy& security>allow all cookies. I don't like this solution all that much though.

EDIT: ah, I found this in the documentation: https://www.npmjs.com/package/react-google-login#onfailure-callback

rahuls360 commented 3 years ago

In my case, I was using incognito mode in Chrome and was facing this error. Turns out, that this issue is because cookies are not enabled in incognito mode/guest mode. This could be a possible workaround - https://stackoverflow.com/questions/63631849/google-sign-in-not-working-in-incognito-mode , I haven't tried it out yet though

nhidangsd commented 3 years ago

02/21: I just bumped into this issue on Chrome. Clearing the Cached images and files did fix the issue.

peterkapena commented 3 years ago

So having this issue opened in 2021 means this is still outstanding. Of course clearing cache solves the problem but this cannot be the ultimate solution telling your users to clear cache all the time they have to use the site.

Will we ever get this fixed?

harsh-vish14 commented 3 years ago

This same is there with me I have just stop blocking cookies at the top right there is an eye just click on that allow all cookies

This solved my issue image

luchillo17 commented 3 years ago

I'm running this in an ElectronJS app, can't find any docs about how to enable 3rd party cookies, so had to force a reload when this specific error shows and hope it was actually logged correctly, anyone knows how to fix this in Electron?

wecoon commented 3 years ago

It seems that I was getting this error when I allowed site in Facebook container. This is Firefox feature to block Facebook tracking, and it also blocks login via Facebook.

I was implementing Facebook login too, so I had to allow it, but it brake Google login.. somehow.

JanSeulin commented 3 years ago

I was having this problem on Firefox only. Of all solutions listed here the only one that worked was mentioned by ap0ca. Turns out in my case it was the "Google Container" extension, after disabling it, it's working again. If nothing else mentioned works I would advise to try disabling all extensions like adblocks, tracker blockers, etc

bmmathe commented 3 years ago

I was experiencing the same problem here. It was resolved when I re-created google credentials.

Go to https://console.developers.google.com/apis, and in the Google Plus API, access credentials, and create a new credential for "Oauth Client Id". In the "Application Type" select "Web Application". Be sure to put the full address of where the API is being called in the "Authorized redirect URIs". Finally, use the new "Client ID" that will be generated.

Despite this, the message displayed ("popup_closed_by_user") is not correct, so I believe the issue should be kept open.

This worked for me but when I re-created the client credential I didn't add a web server Authorized Redirect URI. I'm not sure if this matters.

henrymcl commented 2 years ago

I encountered this issue after upgrading helmetjs from 4.6.0 to 5.0.0. When I tried removing the helmet middleware (or downgrading), the issue was gone. Here's the config I supplied to helmet which had worked in 4.6.0 but not 5.0.0

{
  contentSecurityPolicy: {
    directives:{ 
      ...helmet.contentSecurityPolicy.getDefaultDirectives(),
      'script-src': ["'self'", "https://apis.google.com/"],
      'frame-src': ["'self'", "https://accounts.google.com/"]
    }
  }
}

There are some breaking changes, namely:

While the version update is on 2022-01-03 and is very unlikely to be the root cause to your issue, these policies can be a good starting point to look at. (I'm still learning about those policies and can't give a definitive answer)

UPDATE The culprit is apparently cross-origin-opener-policy. Helmet uses the strictest same-origin while same-origin-allow-popups resolves the "popup_closed_by_user" issue in my case. More helpful error messages would indeed help.

nadeemkhan02 commented 2 years ago

clearing the cache didn't work for me!

nadeemkhan02 commented 2 years ago

Clearing the cache doesn't strike me as a good solution if you're trying to make sure your users aren't hit with this error.

This solution worked for me: #132 (comment)

can you please explain the solution?

LuisJoseLopezD commented 2 years ago

cache thing, does not work!!!

kasvith commented 2 years ago

Im having the same issue

Infinitay commented 2 years ago

I'm having the same issue when deploying my React app to GitHub Pages.

EDIT: After a few hours it ended up working. I'm not sure if its because I put every single denomination of the redirect uri on Google's credential page or if its because it really did take a few hours to update like the page said.

kasvith commented 2 years ago

For anyone who is struggling with this, try to use the following library

https://www.npmjs.com/package/@react-oauth/google

Google requires new OAuth clients to use the latest library, otherwise old library does not properly initialize, hence leads to this error.

I solved this simply by using the library mentioned above

AlekseiKromski commented 2 years ago

For anyone who is struggling with this, try to use the following library

https://www.npmjs.com/package/@react-oauth/google

Google requires new OAuth clients to use the latest library, otherwise old library does not properly initialize, hence leads to this error.

I solved this simply by using the library mentioned above

Thank you, bcs i try to work with a lot of vue3 libraries for google sigin button and anyone not working 😠. Who will read it, try to create by Google api your custom solution or wait, were someone create working library