Jwt-auth: Non-static method JWTAuth::attempt()

Created on 13 May 2017  路  11Comments  路  Source: tymondesigns/jwt-auth

Non-static method Tymon\JWTAuth\JWTAuth::attempt() should not be called statically

use TymonJWTAuthJWTAuth;
....
if (!$token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'invalid_credentials'], 401);
}

app.php
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,

Most helpful comment

You need to

use JWTAuth;

instead of

use Tymon\JWTAuth\JWTAuth;

Because you have already added the JWTAuth alias to 'app.php'.

Take a look at the creating tokens examples.

All 11 comments

You need to

use JWTAuth;

instead of

use Tymon\JWTAuth\JWTAuth;

Because you have already added the JWTAuth alias to 'app.php'.

Take a look at the creating tokens examples.

Image of Yaktocat

Oh, are you using 1.0.0-beta or 0.5.11?

0.5.11

This works, then embarrasses the code highlighting

@sayber this is solved?

i have same problem please help

me too for 0.5.*

We offten use this

use Tymon\JWTAuth\JWTAuth;

In fact, it use this one

use Tymon\JWTAuth\Facades\JWTAuth;

I have config this in App.php ['aliases']
So, we instead

use Tymon\JWTAuth\JWTAuth;

to

use JWTAuth;

me too for 1.0.0.*
I have config this in APP.php ['aliases']
'JWTAuth' => TymonJWTAuthFacadesJWTAuth::class,
So,i instead
use TymonJWTAuthJWTAuth;
to
use JWTAuth;
but,it't not works!why?it tip me the JWTAuth is not defined

please instead configjwt..php : 'jwt' => 'Tymon\JWTAuth\Providers\JWT\NamshiAdapter', as 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class , 'auth' => 'Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter' as 'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class , 'storage' => 'Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter' as 'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class

Was this page helpful?
0 / 5 - 0 ratings

Related issues

functionpointdaniel picture functionpointdaniel  路  3Comments

loic-lopez picture loic-lopez  路  3Comments

Rasoul-Karimi picture Rasoul-Karimi  路  3Comments

therealmjk picture therealmjk  路  3Comments

johncloud200 picture johncloud200  路  3Comments