Google identity is not calling callback in react

Viewed 112

This code is simply not calling the callback. I can see it's logged me in as a SPAN element is injected into the domain saying 'logged in as x@x.com'

The pop-up opens up and I can select the correct account. I've set the correct authorised domains.The google client ID is correct.

I am getting a "Indicate whether to send a cookie in a cross-site request by specifying its SameSite attribute" for the google cookies 9such as SMSV etc) but I'm not sure whether that's affecting anything?

const handleCredentialResponse = (response) =>  {
    console.log("called");
    alert(response.credential);

  };

  const responseGoogleFail = (response) => {
    console.log(response);
  };

  return (
    <div>
      <div
        id="g_id_onload"
        data-client_id={process.env.REACT_APP_GOOGLECLIENTID}
        data-context="signin"
        data-ux_mode="popup"
        data-callback="handleCredentialResponse"
        data-auto_prompt="false"
      ></div>

      <div
        class="g_id_signin"
        data-type="standard"
        data-shape="pill"
        data-theme="outline"
        data-text="signin_with"
        data-size="large"
        data-logo_alignment="left"
      ></div>
    </div>
  );
}
0 Answers
Related