src/API.php
private function getAccessToken($email, $password, $clientConfig)
    {
        $oauth2Config = $clientConfig['oauth2'];
        $accessToken = null;

        // If there is a token file, try to read it and test the found token
        try {
            $filePath = array_key_exists('token_file_path', $oauth2Config) && !empty($oauth2Config['token_file_path'])
                ? $oauth2Config['token_file_path'] : '';

            if (file_exists($filePath)) {
                $data = file_get_contents($filePath);

                if (!empty($data)) {
                    $decodedData = json_decode($data);
                    $accessToken = $decodedData->access_token;

                    return $accessToken;
                }
            }
        } catch (\Exception $e) {
        }

        return $this->createAccessToken($email, $password, $clientConfig);
    }
private function getAccessToken($email, $password, $clientConfig)
    {
        $oauth2Config = $clientConfig['oauth2'];
        $accessToken = null;

        // If there is a token file, try to read it and test the found token
        try {
            $filePath = array_key_exists('token_file_path', $oauth2Config) && !empty($oauth2Config['token_file_path'])
                ? $oauth2Config['token_file_path'] : '';

            if (file_exists($filePath)) {
                $data = file_get_contents($filePath);

                if (!empty($data)) {
                    $decodedData = json_decode($data);
                    $accessToken = $decodedData->access_token;

                    return $accessToken;
                }
            }
        } catch (\Exception $e) {
        }

        return $this->createAccessToken($email, $password, $clientConfig);
    }
private function getAccessToken ( $ email , $ password , $ clientConfig ) { $ oauth2Config = $ clientConfig [ 'oauth2' ] ; $ accessToken = null ; // If there is a token file, try to read it and test the found token try { $ filePath = array_key_exists ( 'token_file_path' , $ oauth2Config ) && ! empty ( $ oauth2Config [ 'token_file_path' ] ) ? $ oauth2Config [ 'token_file_path' ] : '' ; if ( file_exists ( $ filePath ) ) { $ data = file_get_contents ( $ filePath ) ; if ( ! empty ( $ data ) ) { $ decodedData = json_decode ( $ data ) ; $ accessToken = $ decodedData -> access_token ; return $ accessToken ; } } } catch ( \ Exception $ e ) { } return $ this -> createAccessToken ( $ email , $ password , $ clientConfig ) ; }
Gets an access token either from config, from disk or by requesting a new one

@param $email
@param $password
@param $clientConfig
@return string|null
@throws Exception
Gets an access token either from config from disk or by requesting a new one