Google Identity Services Login with React

Viewed 144

I'm trying to implement Google Identity Services Login without third parties, everything works well because I get the response when I try to sign in, except for the error shown in the console:

"Failed to load resource: the server responded with a status of 401 ()"

This is my code:

useEffect(() => {
    try {
      google.accounts.id.initialize({
        client_id:
          "CODE.apps.googleusercontent.com",
        callback: handleCallbackResponse,
      });

      google.accounts.id.renderButton(document.getElementById("buttonDiv"), {
        theme: "outline",
        size: "large",
        text: "continue_with",
      });

      window.google.accounts.id.prompt();
    } catch (e) {
      alert("Error", e);
    }
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);


function handleCallbackResponse(response) {
    //code
  }

return (<div id="buttonDiv"></div>)
0 Answers
Related