anthonyjgrove / react-google-login

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

GoogleLogin button is making requests to google api without user interaction. #412

Open MrUsefull opened 3 years ago

MrUsefull commented 3 years ago

I've created a demo app here demonstrating the behavior.

Here are request logs for the demo app above after running npm start with no user interaction:

GEThttp://localhost:3000/ [HTTP/1.1 304 Not Modified 1ms]

GEThttp://localhost:3000/static/js/bundle.js [HTTP/1.1 304 Not Modified 1ms]

GEThttp://localhost:3000/static/js/0.chunk.js [HTTP/1.1 304 Not Modified 16ms]

GEThttp://localhost:3000/static/js/main.chunk.js [HTTP/1.1 304 Not Modified 18ms]

GEThttp://localhost:3000/static/js/0.chunk.js [HTTP/1.1 200 OK 0ms]

GETws://localhost:3000/sockjs-node [HTTP/1.1 101 Switching Protocols 5ms]

GEThttps://apis.google.com/js/api.js [HTTP/2 304 Not Modified 40ms]

GEThttps://apis.google.com/js/api.js [HTTP/2 200 OK 0ms]

GEThttps://apis.google.com//scs/apps-static//js/k=oz.gapi.en_US.sazTpAB7NWc.O/m=auth2/rt=j/sv=1/d=1/ed=1/am=wQE/rs=AGLTcCMGRnMhese6OTxesnN0rDvhruAGIg/cb=gapi.loaded_0 [HTTP/2 200 OK 0ms]

GEThttps://apis.google.com//scs/apps-static//js/k=oz.gapi.en_US.sazTpAB7NWc.O/m=auth2/rt=j/sv=1/d=1/ed=1/am=wQE/rs=AGLTcCMGRnMhese6OTxesnN0rDvhruAGIg/cb=gapi.loaded_0 [HTTP/2 200 OK 0ms]

GEThttp://localhost:3000/logo192.png [HTTP/1.1 200 OK 0ms]

GEThttp://localhost:3000/favicon.ico [HTTP/1.1 200 OK 0ms]

GEThttps://accounts.google.com/o/oauth2/iframe#origin=http%3A%2F%2Flocalhost%3A3000&rpcToken=432349172.2282647 [HTTP/2 200 OK 43ms]

GEThttps://ssl.gstatic.com/accounts/o/299200676-idpiframe.js [HTTP/2 200 OK 0ms]

GEThttps://ssl.gstatic.com/accounts/o/299200676-idpiframe.js

jblevins1991 commented 3 years ago

I am also having this same issue. The request is being sent without interaction.

Migggz commented 3 years ago

I'm facing the same issue

krishnaTORQUE commented 3 years ago

yes I was facing this same issue. use prop autoLoad={false} this will solve the issue

MrUsefull commented 3 years ago

The demo repo shows the issue with autoload set to false: https://github.com/MrUsefull/react-google-login-auto-demo/blob/master/src/App.js

pankajchaturvedi2244 commented 3 years ago

any update on this?

adeeltechmate commented 3 years ago

i also face this issue

<GoogleLogin
                          className="btn btn-dark-outline btn-lg"
                          render={(renderProps) => (
                            <CButton
                              block
                              color="dark"
                              variant="outline"
                              size="lg"
                              onClick={renderProps.onClick}
                            >
                              <img
                                className="mr-3"
                                width="18"
                                src={googleIcon}
                                alt="icon"
                              />
                              Sign up with Google
                            </CButton>
                          )}
                          clientId={
                            process.env.REACT_APP_GOOGLE_CLIENT_ID 
                          }
                          onSuccess={handleGoogleSignUp}
                          onFailure={handleGoogleSignUp}
                          cookiePolicy={"single_host_origin"}
                          autoLoad={false}
                          isSignedIn={false}
                        />
zhuhang-jasper commented 3 years ago

any update on this? project seems inactive.

on page load, the onSuccess callback will be triggered automatically, even if I set autoLoad = {false}

bohdan-vasylenko commented 2 years ago

Looks like the lack of error handling creates this issue. same here. In my case the error was {error: 'idpiframe_initialization_failed', details: 'Cookies are not enabled in current environment.'} So basically the button checks the config and throws an error immediately after rendering

mcmxcdev commented 2 years ago

Is there any workaround for this issue? autoload prop doesn't work.

Is there any similar lib like this? Critical bug that we can't release with.

tutanck commented 2 years ago

Same here : onAutoLoadFinished is called with 'true' even if autoLoad is set to false.

NimaChamika commented 2 years ago

when run it on http, I got the issue. after run it on https there was no auto calling issue.

lukestewart13 commented 2 years ago

If your browser is blocking third-party cookies, then Google with throw an error as soon as the button renders. The workaround would be to store whether the the button has been clicked, and then display the error only after the button has been clicked. Note the error thrown post-click is often different from the error thrown pre-click.

rcastro-uy commented 2 years ago

Any update on this? The prop autoload doesn't work.

sardar-ali commented 2 years ago

I faced to same issue. i resolved it just using
onAutoLoadFinished={true} it may help.

ghost commented 2 years ago

This is also not working and it is rendering automatically. Can someone please have a look at this ?

SpurgeonPrakash commented 2 years ago

autoLoad property isn't working for me too. any workarounds?