Php 未捕获异常';无效辩论例外';带有消息';无效的json令牌';

Php 未捕获异常';无效辩论例外';带有消息';无效的json令牌';,php,json,google-api-php-client,Php,Json,Google Api Php Client,您好,我在尝试使用google/apiclient时遇到问题 致命错误:C:\xampp\htdocs\Google\vendor\Google\apiclient\src\Google\Client.php:422堆栈跟踪:#0 C:\xampp\htdocs\Google\app\class\Google\u auth.php(43):Google\u Client->setAccessToken(NULL)#1 C:\xampp\htdocs\Google\app\class\Google

您好,我在尝试使用google/apiclient时遇到问题

致命错误:C:\xampp\htdocs\Google\vendor\Google\apiclient\src\Google\Client.php:422堆栈跟踪:#0 C:\xampp\htdocs\Google\app\class\Google\u auth.php(43):Google\u Client->setAccessToken(NULL)#1 C:\xampp\htdocs\Google\app\class\Google\u auth.php(34):GoogleAuth->setToken(NULL)#2 C:\xampp\htdocs\Google\index.php(10):GoogleAuth->checkRedirectCode()#3{main}在第422行的C:\xampp\htdocs\Google\vendor\Google\apiclient\src\Google\Client.php中抛出

我的索引:

<?php
    require_once('app/ini.php');
    require_once('vendor/autoload.php');
    require_once('app/class/google_auth.php');


    $googleClient = new Google_Client();
    $auth = new GoogleAuth($googleClient);

    if ($auth->checkRedirectCode()) {
        header("Location: index.php");
    }

?>

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>

    <?php if (!$auth->isLoggedIn()): var_dump($auth->isLoggedIn()); //Verificar Inicio de Sesion ?>
        <a href="<?php echo $auth->getAuthUrl(); ?>">Inicie Sesion con Google</a>
    <?php else: //Si no ha iniciado Sesion ?>
        Bienvenido.. <a href="logout.php">Cerrar Sesion</a>
    <?php endif; ?> 

</body>
</html>

比恩维多。。
GoogleAuth类:

<?php

    class GoogleAuth{//Clase para la autenticacion del usuario google

        protected $client;//Variable de cliente

        public function __construct(Google_Client $googleClient = null){
            $this->client = $googleClient;

            if ($this->client) {

                $this->client->setClientId('474251646530-0tiho0cbf4d1ti864ck5d1nk8rh5pcb6.apps.googleusercontent.com');//Usuario Auth Google
                $this->client->setClientSecret('
                    bMuLusxZW6ohlI3vnvPg2zRz');//Clave Auth Google
                $this->client->setRedirectUri('http://localhost/Google/index.php');
                $this->client->setScopes('email');

            }
        }

        public function isLoggedIn(){//Metodo que devuelve el estatus de la Sesion con Google (true o false)
            return isset($_SESSION['access_token']);

        }

        public function getAuthUrl(){//Funcion que devuelve el enlace requerido para iniciar sesion
            return $this->client->createAuthUrl();

        }

        public function checkRedirectCode(){
            if (isset($_GET['code'])) {
                $this->client->authenticate($_GET['code']);
                $this->setToken($this->client->getAccessToken());

                return true;
            }
            return false;
        }

        public function setToken($token){
            $_SESSION['access_token']=$token;
            $this->client->setAccessToken($token);
        }

        public function logout(){
            unset($_SESSION['access_token']);
        }

    }

?>


getAccessToken()
正在返回
NULL

对我来说,问题可能就在这里

$this->client->setClientSecret('
                bMuLusxZW6ohlI3vnvPg2zRz');//Clave Auth Google
除非这是复制/粘贴错误

$this->client->setClientSecret('bMuLusxZW6ohlI3vnvPg2zRz');//Clave Auth Google

首先,我要做的就是修复它

在我看来,问题可能就在这里

$this->client->setClientSecret('
                bMuLusxZW6ohlI3vnvPg2zRz');//Clave Auth Google
除非这是复制/粘贴错误

$this->client->setClientSecret('bMuLusxZW6ohlI3vnvPg2zRz');//Clave Auth Google
首先,我要做的就是修复它