sizeg / yii2-jwt

A simple Yii2 component to work with JSON Web Token and JSON Web Signature
https://jwt.io/
196 stars 85 forks source link

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

Open jordanfrancis opened 1 year ago

jordanfrancis commented 1 year ago

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();
    }
}
charlietyn commented 8 months ago

Did you solve this issue

FredCinePostProd commented 8 months ago

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

jordanfrancis commented 8 months ago

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

charlietyn commented 8 months ago

i fix the problem with sizeg already

byStrange commented 17 hours ago

@charlietyn how did u fix it with sizeg?