agungsugiarto / codeigniter4-authentication-jwt

JSON Web Token for codeigniter4-authentication. This package is port from tymondesigns/jwt-auth for compability with agungsugiarto/codeigniter4-authentication.
MIT License
27 stars 7 forks source link

Problem Generating Token #3

Closed MartinPessoa closed 3 years ago

MartinPessoa commented 3 years ago

Hi,

I installed your library, but there was a problem in "Providers\JWT\Lcobucci.php" in function encode(array $payload). Problem was this line:

$this->builder->withClaim($key, $value);

since "Lcobucci\JWT\Builder" class has no function with that name (withClaim). PHP error below:

"Call to undefined method Lcobucci\JWT\Builder::withClaim()",

I think I got it working by doing the following:

     foreach ($payload as $key => $value) {
            $this->builder->set($key, $value);
        }

        $this->builder->sign($this->signer, $this->getSigningKey());

        $tok_return = $this->builder->getToken()->__toString();

        return $tok_return;
agungsugiarto commented 3 years ago

Hello Martin,

This library need "lcobucci/jwt": "<3.4"

MartinPessoa commented 3 years ago

Oh, ok, maybe it was related to "lcobucci/jwt" version.

However, I installed your library with composer according to readme.md and it installed "lcobucci/jwt"->"version": "3.2.5",

my composer.lock:

  "name": "agungsugiarto/codeigniter4-authentication-jwt",
        "version": "dev-master",
        (...)
        "require": {
            "agungsugiarto/codeigniter4-authentication": "^1.0",
            "codeigniter4/framework": "^4.1",
            "lcobucci/jwt": "<3.4",
        (...)
        "name": "lcobucci/jwt",
        "version": "3.2.5",

Now I confirmed "lcobucci/jwt" v3.3 has this method withClaim, so i guess i should update to v3.3.

Thanks!