在 react-google-login 中出现“缺少必需的参数‘client_id’”错误

时间:2020-12-22 05:51:23

标签: reactjs google-oauth google-login

我正确插入了我的客户端 ID,它确实有效

但突然它直到现在都不起作用,即使我没有更改 <GoogleLogin />

中的任何代码

当我测试但不在这个项目中工作时,它也可以在空白 React 中工作

确切的错误信息是 Uncaught qw {message: "Missing required parameter 'client_id'", xM: true, stack: "gapi.auth2.ExternallyVisibleError: Missing require…YZKdHMHzzbYNF1G7KSEIjXaBQQw/cb=gapi.loaded_0:1:15"}

import React, { useState } from "react";
import "./CSS/Header.css";
import { BrowserRouter as Router, Link } from "react-router-dom";
import { GoogleLogin } from "react-google-login";
export default function Header() {
  const responseGoogle = (response) => {
    console.log(response);
  };
  return (
    <Router>
      <div id="header">
        <div id="id"></div>
        <h2 id="header_title">title</h2>
        <div id="contents">
          <h4 className="content">
            <Link
              to="/"
              onClick={() => {
                window.location.href = "/";
              }}
            >
              HOME
            </Link>
          </h4>
          <h4 className="content">
            <Link
              to="/history"
              onClick={() => {
                window.location.href = "/history";
              }}
            >
              History
            </Link>
          </h4>
          <GoogleLogin
            clientid=[myclientid]
            buttonText="Login"
            onSuccess={responseGoogle}
            isSignedIn={true}
            onFailure={responseGoogle}
            cookiePolicy={"single_host_origin"}
          />
        </div>
      </div>
    </Router>
  );
}

1 个答案:

答案 0 :(得分:0)

你应该使用 E/flutter (24806): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Connection closed while receiving data 而不是 Keep-Alive 作为道具