google-api-php-client icon indicating copy to clipboard operation
google-api-php-client copied to clipboard

Fatal error with phpseclib in release asset 2.9.1

Open kungufli opened this issue 4 years ago • 1 comments

Using the downloaded package (not installed through composer) version 2.9.1, the following error is thrown when trying to use a phpseclib dependency:

Fatal error: Uncaught RuntimeException: Please require phpseclib/phpseclib v2 to use this utility.

This error doesn't appear in version 2.8.2.

Environment details

  • OS: macOS 11.2.3 / Ubuntu 20.04.2.0 LTS
  • PHP version: 7.4
  • Package name and version: google-api-php-client-v2.9.1-PHP7.4

Steps to reproduce

  1. Download google-api-php-client-v2.9.1-PHP7.4
  2. Create a simple php script that use any client's function that requires phpseclib (see example below).
  3. Execute the script and see the fatal error message about phpseclib.

Code example

<?php

require_once 'google-api-php-client-v2.9.1-PHP7.4/vendor/autoload.php';

$jwt = '';
$accessTokenUtility = new \Google\Auth\AccessToken;
$accessTokenUtility->verify($jwt);


?>

Error stack trace example

PHP Fatal error:  Uncaught RuntimeException: Please require phpseclib/phpseclib v2 to use this utility. in /Users/aprete/Desktop/PHPTest/google-api-php-client-v2.9.1-PHP7.4/vendor/google/auth/src/AccessToken.php:401
Stack trace:
#0 /Users/aprete/Desktop/PHPTest/google-api-php-client-v2.9.1-PHP7.4/vendor/google/auth/src/AccessToken.php(236): Google\Auth\AccessToken->checkAndInitializePhpsec()
#1 /Users/aprete/Desktop/PHPTest/google-api-php-client-v2.9.1-PHP7.4/vendor/google/auth/src/AccessToken.php(134): Google\Auth\AccessToken->verifyRs256('', Array, NULL, NULL)
#2 /Users/aprete/Desktop/PHPTest/test.php(8): Google\Auth\AccessToken->verify('')
#3 {main}
  thrown in /Users/aprete/Desktop/PHPTest/google-api-php-client-v2.9.1-PHP7.4/vendor/google/auth/src/AccessToken.php on line 401

kungufli avatar Mar 10 '21 16:03 kungufli

@kungufli thanks for raising this 👍.

It looks like the check we rely on doesn't account for the fact phpseclib updated their root namespace for version 3. As you noted, pinning to 2.8.2 or explicitly requiring phpseclib ~2 should work for now. We'll work on getting this fixed.

dwsupplee avatar Mar 11 '21 17:03 dwsupplee