Closed megatronskneecap closed 5 months ago
I'm getting this error too and I'm using PHP 8.1.27 and the same Firebase library version as you specified
Hi @megatronskneecap , thanks for raising this issue. Can you please paste the whole stack trace and error message here?
I am also getting this error. PHP v8.1.10 and firebase/php-jwt : v6.10.0
Error: Firebase\JWT\JWT::decode(): Argument #3 ($headers) cannot be passed by reference in League\OAuth2\Client\Token\AppleAccessToken->__construct() (line 50 of ...project_path..\vendor\patrickbussmann\oauth2-apple\src\Token\AppleAccessToken.php)
Did anybody every find a solution to this @megatronskneecap ?
Did anybody every find a solution to this @megatronskneecap ?
I'm yet to find a solution, I just switched JWT debug libraries.
Did anybody every find a solution to this @megatronskneecap ?
I'm yet to find a solution, I just switched JWT debug libraries.
What library did you use
Hi @megatronskneecap , since the third argument of the decode
method is a reference, that's why it becomes mandatory to pass a variable containing the value instead of just the value.
This would fail
$decoded = JWT::decode($jwtToken, $key, ['HS256', 'headers' => $headers]);
Whereas this would pass
$arg = ['HS256', 'headers' => $headers];
$decoded = JWT::decode($jwtToken, $key, $arg);
Try writing it like this:
use Firebase\JWT\Key;
$decoded = JWT::decode($jwt, new key ($key, 'HS256'))
Hope this helps 😊
I encountered a similar problem
require 'vendor/autoload.php';
use Firebase\JWT\JWT;
use Firebase\JWT\ExpiredException;
use Firebase\JWT\SignatureInvalidException;
define('SECRET_KEY', '123456');
$decoded = JWT::decode($token, SECRET_KEY, ['HS256']);
Fatal error: Uncaught Error: Firebase\JWT\JWT::decode(): Argument #3 ($headers) cannot be passed by reference
$headers = cloneHeaders(apache_request_headers());
$arg = ['HS256', 'headers' => $headers];
$decoded = JWT::decode($token, SECRET_KEY, $arg);
Fatal error: Uncaught TypeError: Firebase\JWT\JWT::decode(): Argument #3 ($headers) must be of type ?stdClass, array given
$decoded = JWT::decode($token, new key (SECRET_KEY, 'HS256'));
Fatal error: Uncaught Error: Class "key" not found
JWT::decode($jwt, new key ($key, 'HS256'))
Worked, the example in README wasn't working!
Admittedly, i've been a bit cheeky here. I've gotten ChatGPT 3.5 to generate me some code for a get user data page* for an admin page i'm trying to create. The code being:
Everytime I run this code I get in the console: Uncaught Error: Firebase\JWT\JWT::decode(): Argument #3 ($headers) cannot be passed by reference in (C directory blablabla). I'm using PHP 8.3.1 and Firebase PHP JWT 6.10 - Please help!