Service/ClientProvider.php
public function isTokenValid(string $tokenName = null): bool
    {
        // We must fetch the client here. A client will automatically refresh the stored access token.
        $client = $this->getClient($tokenName);
        if (null === $accessToken = $client->getAccessToken()) {
            return false;
        }

        // Get the token string from access token
        $token = \json_decode($accessToken)->access_token;
        $url = \sprintf('https://www.google.com/accounts/AuthSubTokenInfo?bearer_token=%s', $token);
        if (false === @\file_get_contents($url)) {
            return false;
        }

        // Retrieve HTTP status code
        list($version, $statusCode, $msg) = \explode(' ', $http_response_header[0], 3);

        return 200 === (int) $statusCode;
    }
public function isTokenValid(string $tokenName = null): bool
    {
        // We must fetch the client here. A client will automatically refresh the stored access token.
        $client = $this->getClient($tokenName);
        if (null === $accessToken = $client->getAccessToken()) {
            return false;
        }

        // Get the token string from access token
        $token = \json_decode($accessToken)->access_token;
        $url = \sprintf('https://www.google.com/accounts/AuthSubTokenInfo?bearer_token=%s', $token);
        if (false === @\file_get_contents($url)) {
            return false;
        }

        // Retrieve HTTP status code
        list($version, $statusCode, $msg) = \explode(' ', $http_response_header[0], 3);

        return 200 === (int) $statusCode;
    }
public function isTokenValid ( string $ tokenName = null ) : bool { // We must fetch the client here. A client will automatically refresh the stored access token. $ client = $ this -> getClient ( $ tokenName ) ; if ( null === $ accessToken = $ client -> getAccessToken ( ) ) { return false ; } // Get the token string from access token $ token = \ json_decode ( $ accessToken ) -> access_token ; $ url = \ sprintf ( 'https://www.google.com/accounts/AuthSubTokenInfo?bearer_token=%s' , $ token ) ; if ( false === @ \ file_get_contents ( $ url ) ) { return false ; } // Retrieve HTTP status code list ( $ version , $ statusCode , $ msg ) = \ explode ( ' ' , $ http_response_header [ 0 ] , 3 ) ; return 200 === ( int ) $ statusCode ; }
Check if a token is valid.
This is an expensive operation that makes multiple API calls.
Check if a token is valid . This is an expensive operation that makes multiple API calls .