Code Monkey home page Code Monkey logo

Comments (13)

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

I have seen this error randomly but have not be able to reproduce it. Do you have repo steps and does it keep you from authenticating?

from react-google-login.

isaachinman avatar isaachinman commented on May 27, 2024

No, it doesn't prevent authentication, it's just a warning. My implementation is more or less identical to the docs, maybe it's environment specific. I'll see if I can set up a jsFiddle.

Surely it's just a matter of heeding the warning itself, though? Do you call gapi.auth2.init() or gapi.auth2.getAuthInstance() in the source code?

from react-google-login.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

It uses both. It sounds like it is calling gapi.auth2.init() when it shouldn't be or is called with different options. Let me know if you can give me repo steps or a link to so we can figure out the scenario which the error is occurring.

from react-google-login.

isaachinman avatar isaachinman commented on May 27, 2024

Sure, do you have a demo clientId to use?

from react-google-login.

isaachinman avatar isaachinman commented on May 27, 2024

Ah, I see you've got one in the demo. In that case, here's my implementation:

<GoogleLogin
    style={styles.googleBtn}
    buttonText='Login with Google'
    callback={this.handleGoogleLogin}
    clientId='658977310896-knrl3gka66fldh83dao2rhgbblmd4un9.apps.googleusercontent.com'
    cssClass='btn btn-block btn-lg btn-default'
 />

from react-google-login.

isaachinman avatar isaachinman commented on May 27, 2024

Basically, it looks like it's happening because your source code is trying to init gapi twice. If I hard reload the page and am not logged into Google, everything looks good. Then I log in. From this point onwards, anytime I come back to this route (eg the component is rendered again) it produces the error because it keeps trying to init gapi.

Why do you use both? The warning seems to indicate if you just stick with gapi.auth2.getAuthInstance() you won't have a problem.

from react-google-login.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

Can you host it somewhere? With it showing the issue. I have a hosted implementation here but it does not show the error: http://reactstarter.founderstack.io/register

from react-google-login.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

It needs Init, if you are not auth'd yet. So it is happening when you hit that page even though you already authenticated? I guess I need a way to check if auth'd before calling init()

from react-google-login.

isaachinman avatar isaachinman commented on May 27, 2024

Did you mean to link to that registration page...?

It's hard to host this kind of stuff, jsFiddle and requirebin don't suffice and don't support ES6/npm.

Basically what you're saying is right; you need to check gapi.auth2.getAuthInstance() before calling gapi.auth2.init(). Should be a simple fix, also happy to submit a PR.

from react-google-login.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

I am traveling right now so wouldn't be able to look at the PR until next weekend but would be great if you could submit one for this.

from react-google-login.

isaachinman avatar isaachinman commented on May 27, 2024

Sure, but what port do you use for local testing? Tried booting the project up on 3000 and got the redirect_uri_mismatch error. Need to know exactly what you've specified the origin to be in your google dev console.

from react-google-login.

anthonyjgrove avatar anthonyjgrove commented on May 27, 2024

Would have to look. Just use your own clientId.

from react-google-login.

isaachinman avatar isaachinman commented on May 27, 2024

I addressed this in PR #12.

from react-google-login.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.