Loc Dai Le
Loc Dai Le

Reputation: 1697

JWT-Token: Class 'Tymon\JWTAuth\Providers\JWTAuthServiceProvider' not found

I'm using this guide https://scotch.io/tutorials/token-based-authentication-for-angularjs-and-laravel-apps#installing-the-angularjs-dependencies to implement JWT-token, but when I come to the section where I want to test my API i get this error:

Class 'Tymon\JWTAuth\Providers\JWTAuthServiceProvider' not found

No matter which route I try to access this error pops up. I'm quite new at laravel so I can't figure out what is wrong, or what I'm not doing right - Thank you.

Upvotes: 1

Views: 2788

Answers (2)

Tobin
Tobin

Reputation: 2018

For anyone who is finding this question from the scotch.io tutorial (excellent tutorial btw), the problem is that these lines:

'JWTAuth'   => Tymon\JWTAuthFacades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuthFacades\JWTFactory::class

Should be this (extra \):

'JWTAuth'   => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class

Upvotes: 3

Omkar Gokhale
Omkar Gokhale

Reputation: 391

I think you forgot to use facade

use Tymon\JWTAuth\Facades\JWTAuth;

Try adding this line at the top of your controller

Upvotes: 1

Related Questions