Google API无效授予不良要求

发布于 2025-01-23 17:07:56 字数 1514 浏览 0 评论 0原文

尝试连接Web应用程序时,我会在PHP中遇到此错误:

致命错误:und offeraghen \ service \ exception:{“ error”:“ invalid_grant”,“ error_description”:“ prad request”} in /var /var /wwwww /vhosts/kabengestiondeagendas.com/httpdocs/cada/vendor/google/apiclient/src/Http/REST.php:128 Stack trace: #0 /var/www/vhosts/kabengestiondeagendas.com/httpdocs/cada/vendor/google/ apiclient/src/http/rest.php(103):google \ http \ rest :: decodehttpresponse()#1 [内部函数]:google \ http \ rets :: doexecute(doexecute() 。 src/http/rest.php(66):google \ task \ task \ runner-> run()#4/var/www/www/vhosts/kabengestiondeagendas.com/httpdpdocs/cada/cada/cada/cada/cada/cada/vendor/google/google/google/google/apiclient/src/src/src/client.php/client.php/client.php/ (922):Google \ http \ rest :: execute()#5/var/www/vhosts/kabengestiondeagendas.com/httpdocs/httpdocs/cada/cada/cada/cada/vendor/google/google/apiclient/src/src/service/service/service/resource/resource.php (238) Client->execute() #6 /var/www/vhosts/kabengestiondeagendas.com/httpdocs/cada/vendor/g in /var/www/vhosts/kabengestiondeagendas.com/httpdocs/cada/vendor/google/apiclient/src /http/rest.php在第128行上的

我认为错误是在PHP中的这一代码中:

    if ($client->isAccessTokenExpired()) 
    {
        // the new access token comes with a refresh token as well
        $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
        file_put_contents($TOKEN_FILE, json_encode($client->getAccessToken()));
    }

有人可以帮助我吗?谢谢!!

I get this error in PHP when trying to connect a WEB application:

Fatal error: Uncaught Google\Service\Exception: { "error": "invalid_grant", "error_description": "Bad Request" } in /var/www/vhosts/kabengestiondeagendas.com/httpdocs/cada/vendor/google/apiclient/src/Http/REST.php:128 Stack trace: #0 /var/www/vhosts/kabengestiondeagendas.com/httpdocs/cada/vendor/google/apiclient/src/Http/REST.php(103): Google\Http\REST::decodeHttpResponse() #1 [internal function]: Google\Http\REST::doExecute() #2 /var/www/vhosts/kabengestiondeagendas.com/httpdocs/cada/vendor/google/apiclient/src/Task/Runner.php(182): call_user_func_array() #3 /var/www/vhosts/kabengestiondeagendas.com/httpdocs/cada/vendor/google/apiclient/src/Http/REST.php(66): Google\Task\Runner->run() #4 /var/www/vhosts/kabengestiondeagendas.com/httpdocs/cada/vendor/google/apiclient/src/Client.php(922): Google\Http\REST::execute() #5 /var/www/vhosts/kabengestiondeagendas.com/httpdocs/cada/vendor/google/apiclient/src/Service/Resource.php(238): Google\Client->execute() #6 /var/www/vhosts/kabengestiondeagendas.com/httpdocs/cada/vendor/g in /var/www/vhosts/kabengestiondeagendas.com/httpdocs/cada/vendor/google/apiclient/src/Http/REST.php on line 128

I think the error is in this piece of code in PHP:

    if ($client->isAccessTokenExpired()) 
    {
        // the new access token comes with a refresh token as well
        $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
        file_put_contents($TOKEN_FILE, json_encode($client->getAccessToken()));
    }

Can somebody help me? Thanks!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人│生佛魔见 2025-01-30 17:07:56

我设法使用以下代码撤销了Accestoken:

    session_start();    
    $accesstoken=$_SESSION['access_token'];

    //Unset token and user data from session    
    unset($_SESSION['access_token']);    
    unset($_SESSION['userData']);    

    //Reset OAuth access token    
    $client = new Google_Client();

    //$client->revokeToken();    
    $client->revokeToken($accesstoken);

    //Destroy entire session    
    session_destroy();    

I managed to revoke the accestoken with the following code:

    session_start();    
    $accesstoken=$_SESSION['access_token'];

    //Unset token and user data from session    
    unset($_SESSION['access_token']);    
    unset($_SESSION['userData']);    

    //Reset OAuth access token    
    $client = new Google_Client();

    //$client->revokeToken();    
    $client->revokeToken($accesstoken);

    //Destroy entire session    
    session_destroy();    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文