THAPA TECHNICAL

HOUSE OF WEB DEVELOPERS AND TECHNOLOGY.

Logout.php page code for Google OAuth Login in PHP

Logout.php page code for Google OAuth Login in PHP

<?php

//logout.php

include('config.php');

//Reset OAuth access token
$google_client->revokeToken();

//Destroy entire session data.
session_destroy();

//redirect page to index.php
header('location:index.php');

?>

12 comments:


  1. Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://oauth2.googleapis.com/revoke` resulted in a `400 Bad Request` response: { "error": "invalid_request", "error_description": "Bad Request" } in C:\xampp\htdocs\gopala\gopala_fastion\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:111 Stack trace: #0 C:\xampp\htdocs\gopala\gopala_fastion\vendor\guzzlehttp\guzzle\src\Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 C:\xampp\htdocs\gopala\gopala_fastion\vendor\guzzlehttp\promises\src\Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #2 C:\xampp\htdocs\gopala\gopala_fastion\vendor\guzzlehttp\promises\src\Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 C:\xampp\htdocs\gopala\gopala_fastion\vendor\guzzlehttp\promises\src\TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{clo in C:\xampp\htdocs\gopala\gopala_fastion\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 111

    ReplyDelete
    Replies
    1. revokeToken($accesstoken);

      //Destroy entire session data.
      session_destroy();

      //redirect page to index.php
      header('location:index.php');

      ?>

      Delete

  2. Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 77: error setting certificate verify locations: CAfile: C:\xampp\apache\bin\curl-ca-bundle.crt CApath: none (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\xampp\htdocs\login\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:208 Stack trace: #0 C:\xampp\htdocs\login\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(162): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\xampp\htdocs\login\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(109): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 C:\xampp\htdocs\login\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(45): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #3 C:\xampp\htdocs\login\vendor\guz in C:\xampp\htdocs\login\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 208

    ReplyDelete
  3. on my login webpage on google button it is showing notice session start and file path .

    ReplyDelete

  4. Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://oauth2.googleapis.com/revoke` resulted in a `400 Bad Request` response: { "error": "invalid_request", "error_description": "Bad Request" } in C:\xampp\htdocs\googleyoutubeapi\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:111 Stack trace: #0 C:\xampp\htdocs\googleyoutubeapi\vendor\guzzlehttp\guzzle\src\Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 C:\xampp\htdocs\googleyoutubeapi\vendor\guzzlehttp\promises\src\Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #2 C:\xampp\htdocs\googleyoutubeapi\vendor\guzzlehttp\promises\src\Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 C:\xampp\htdocs\googleyoutubeapi\vendor\guzzlehttp\promises\src\TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() #4 C:\xampp\htdoc in C:\xampp\htdocs\googleyoutubeapi\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 111

    ReplyDelete
    Replies
    1. //logout.php

      include('config.php');

      $accesstoken=$_SESSION['access_token'];

      //Reset OAuth access token
      $google_client->revokeToken($accesstoken);

      //Destroy entire session data.
      session_destroy();

      //redirect page to index.php
      header('location:index.php');

      Use this code in logout.php file...

      Delete
    2. This is working for me. I've placed the access token in the revokeToken(); method.

      Delete

  5. ( ! ) Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\wamp64\www\Ejemplos\Login Gmail\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 201
    ( ! ) GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\wamp64\www\Ejemplos\Login Gmail\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 201

    ReplyDelete
    Replies
    1. /logout.php

      include('config.php');

      $accesstoken=$_SESSION['access_token'];

      //Reset OAuth access token
      $google_client->revokeToken($accesstoken);

      //Destroy entire session data.
      session_destroy();

      //redirect page to index.php
      header('location:index.php');

      Use this code in logout.php file...

      Delete
  6. help

    Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://oauth2.googleapis.com/revoke` resulted in a `400 Bad Request` response: { "error": "invalid_token", "error_description": "Token expired or revoked" } in C:\xampp\htdocs\scripts\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113 Stack trace: #0 C:\xampp\htdocs\scripts\vendor\guzzlehttp\guzzle\src\Middleware.php(69): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), NULL, Array, NULL) #1 C:\xampp\htdocs\scripts\vendor\guzzlehttp\promises\src\Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #2 C:\xampp\htdocs\scripts\vendor\guzzlehttp\promises\src\Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL) #3 C:\xampp\htdocs\scripts\vendor\guzzlehttp\promises\src\TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() #4 C:\xampp\htdocs\scripts\vendor in C:\xampp\htdocs\scripts\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 113

    ReplyDelete