1
votes

I got an issue when I tried to use jwt with laravel "5.5" (this issue only happen on version 5.5)

I'm following this tutorial

and I got this error when I tried to post on postMan

Class 'Tymon\JWTAuth\Providers\JWT\NamshiAdapter' not found

errorMessage

plz help.

I put this issue on github, here is link:


h ttps://github.com/jimmyHuey/jwt-test


2
Please show some code you've tried.Dream_Cap
you probably didn't import the class on top... something like: use Tymon\JWTAuth\Providers\JWT\NamshiAdapter or you didn't register it in service provider... maybe it's an older version of that package that doesn't have auto discovery?lewis4u
@Dream_Cap thanks for reply, I already put this issue on github github.com/jimmyHuey/jwt-testjimmy
@lewis4u sorry, I'm newbie on laravel. Can you tell me where (or which file) to put this import? thanks for help! :) I already put this issue on github:linkjimmy
Never mind I found it....you need to setup a config file did you do that? you must have this file config/jwt.phplewis4u

2 Answers

7
votes

I found my problem.
on config/jwt.php file change following provider :

  1. NamshiAdapter to Namshi
  2. IlluminateAuthAdapter to Illuminate
  3. IlluminateCacheAdapter to Illuminate

then I got this error:

Type error: Argument 1 passed to Tymon\JWTAuth\JWT::fromUser() must be an instance of Tymon\JWTAuth\Contracts\JWTSubject, instance of App\User given, called in /Applications/XAMPP/xamppfiles/htdocs/git/jwt-test/vendor/tymon/jwt-auth/src/JWTAuth.php on line 54

I fix it by implement JWTSubject and modify the class:

namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Tymon\JWTAuth\Contracts\JWTSubject;
class User extends Authenticatable implements JWTSubject
{
    public function getJWTIdentifier()
    {
        return $this->getKey();
    }
    public function getJWTCustomClaims()
    {
        return [];
    }
}
0
votes

I solve this problem by just looking the #1316 issue .

Still can't figure out what's wrong with my project, but at least I find a way to use jwt-auth on laravel 5.5