yii2-jwt icon indicating copy to clipboard operation
yii2-jwt copied to clipboard

Setting unknown property: sizeg\\jwt\\Jwt::jwtValidationData

Open jordanfrancis opened this issue 2 years ago • 5 comments

Hi!

Sorry, I'm new to PHP. I think this issue might be because of autoloading?

Error:

"name": "Unknown Property",
"message": "Setting unknown property: sizeg\\jwt\\Jwt::jwtValidationData",
"code": 0,
"type": "yii\\base\\UnknownPropertyException",
"file": "[/vendor/yiisoft/yii2/base/Component.php](http://localhost:8080/Users/<censored>/venueview-api/vendor/yiisoft/yii2/base/Component.php)",

I have this in my web.php under components:

        'jwt' => [
            'class' => \sizeg\jwt\Jwt::class,
            'key' => '!zf$5obLKs6HeACySCkGafA&*j4jhGt65F@',
            'jwtValidationData' => \app\components\JwtValidationData::class,
        ],

I created a new folder called 'components' with this only file within:

<?php
namespace app\components;

use Yii;

class JwtValidationData extends \sizeg\jwt\JwtValidationData
{
    public function init() {
		$jwtParams = Yii::$app->params['jwt'];
		$this->validationData->setIssuer($jwtParams['issuer']);
		$this->validationData->setAudience($jwtParams['audience']);
		$this->validationData->setId($jwtParams['id']);

		parent::init();
	}
}

jordanfrancis avatar Jan 25 '23 11:01 jordanfrancis

Did you solve this issue

charlietyn avatar Jan 28 '24 05:01 charlietyn

for me the file \sizeg\jwt\JwtValidationData is missing after installing sizeg/yii2-jwt via composer php 8.2

FredCinePostProd avatar Jan 30 '24 15:01 FredCinePostProd

@charlietyn I ended up implementing authentication via https://github.com/lcobucci/jwt instead.

jordanfrancis avatar Jan 30 '24 15:01 jordanfrancis

i fix the problem with sizeg already

charlietyn avatar Jan 30 '24 15:01 charlietyn