title: Authentication with JWT Lumen without password
body: <p>I am using JWT in lumen and am unable to get token without password only With Email and  i am using this code form <a href="https://stackoverflow.com/questions/33028630/authentication-with-jwt-laravel-5-without-password">stack overflow</a> --</p>
  
  <pre><code> $user=User::where('email','=','user2@gmail.com')-&gt;first();
  
  if (!$userToken=JWTAuth::fromUser($user)) {
              return response()-&gt;json(['error' =&gt; 'invalid_credentials'], 401);
          }
  
  return response()-&gt;json(compact('userToken'));
  
  
  
   This code give me error like this -&gt;
  
   ErrorException in UserController.php line 44:
  Non-static method Tymon\JWTAuth\JWT::fromUser() should not be called statically, assuming $this from incompatible context
  </code></pre>
  
  <p>My controller UserController.php -</p>
  
  <pre><code>namespace App\Http\Controllers\v1;
  
  use Illuminate\Http\Request;
  use Illuminate\Http\Response;
  use Exception;
  use Cartalyst\Sentinel\Native\Facades\Sentinel;
  use Cartalyst\Sentinel\Laravel\Facades\Activation;
  use Tymon\JWTAuth\JWTAuth;
  use Illuminate\Support\Facades\Mail;
  use App\Model\User;
  use Tymon\JWTAuth\Exceptions\JWTException;
  use Tymon\JWTAuth\Exceptions\TokenExpiredException;
  use Tymon\JWTAuth\Exceptions\TokenInvalidException;
  </code></pre>
  
  <p>My - Config/auth </p>
  
  <pre><code>&lt;?php
  
  return [
  
      /*
      |--------------------------------------------------------------------------
      | Authentication Defaults
      |--------------------------------------------------------------------------
      |
      | This option controls the default authentication "guard" and password
      | reset options for your application. You may change these defaults
      | as required, but they're a perfect start for most applications.
      |
      */
  
      'defaults' =&gt; [
          'guard' =&gt; env('AUTH_GUARD', 'api'),
          'passwords' =&gt; 'users',
      ],
  
      /*
      |--------------------------------------------------------------------------
      | Authentication Guards
      |--------------------------------------------------------------------------
      |
      | Next, you may define every authentication guard for your application.
      | Of course, a great default configuration has been defined for you
      | here which uses session storage and the Eloquent user provider.
      |
      | All authentication drivers have a user provider. This defines how the
      | users are actually retrieved out of your database or other storage
      | mechanisms used by this application to persist your user's data.
      |
      | Supported: "session", "token"
      |
      */
      'guards' =&gt; [
          'api' =&gt; [
              'driver'     =&gt; 'jwt',
              'provider'   =&gt; 'users',
              'identifier' =&gt; 'email',
              'password'   =&gt; 'password',
          ],
      ],
  
      /*
      |--------------------------------------------------------------------------
      | User Providers
      |--------------------------------------------------------------------------
      |
      | All authentication drivers have a user provider. This defines how the
      | users are actually retrieved out of your database or other storage
      | mechanisms used by this application to persist your user's data.
      |
      | If you have multiple user tables or models you may configure multiple
      | sources which represent each model / table. These sources may then
      | be assigned to any extra authentication guards you have defined.
      |
      | Supported: "database", "eloquent"
      |
      */
  
      'providers' =&gt; [
          'users' =&gt; [
              'driver' =&gt; 'eloquent',
              'model'  =&gt; \App\User::class,
          ],
      ],
  
      /*
      |--------------------------------------------------------------------------
      | Resetting Passwords
      |--------------------------------------------------------------------------
      |
      | Here you may set the options for resetting passwords including the view
      | that is your password reset e-mail. You may also set the name of the
      | table that maintains all of the reset tokens for your application.
      |
      | You may specify multiple password reset configurations if you have more
      | than one user table or model in the application and you want to have
      | separate password reset settings based on the specific user types.
      |
      | The expire time is the number of minutes that the reset token should be
      | considered valid. This security feature keeps tokens short-lived so
      | they have less time to be guessed. You may change this as needed.
      |
      */
  
      'passwords' =&gt; [
          //
      ],
  
  ];
  </code></pre>
  
  <p>My bootstrap/app </p>
  
  <pre><code>&lt;?php
  
  require_once __DIR__ . '/../vendor/autoload.php';
  
  try {
      (new Dotenv\Dotenv(__DIR__ . '/../'))-&gt;load();
  } catch (Dotenv\Exception\InvalidPathException $e) {
      //
  }
  
  /*
    |--------------------------------------------------------------------------
    | Create The Application
    |--------------------------------------------------------------------------
    |
    | Here we will load the environment and create the application instance
    | that serves as the central piece of this framework. We'll use this
    | application as an "IoC" container and router for this framework.
    |
   */
  
  $app = new Laravel\Lumen\Application(
          realpath(__DIR__ . '/../')
  );
  
  $app-&gt;withFacades();
  
  $app-&gt;configure('jwt');
  $app-&gt;configure('auth');
  
  class_alias(Tymon\JWTAuth\Facades\JWTAuth::class, 'JWTAuth');
  class_alias(Tymon\JWTAuth\Facades\JWTFactory::class, 'JWTFactory');
  
  $app-&gt;withEloquent();
  
  /*
    |--------------------------------------------------------------------------
    | Register Container Bindings
    |--------------------------------------------------------------------------
    |
    | Now we will register a few bindings in the service container. We will
    | register the exception handler and the console kernel. You may add
    | your own bindings here if you like or you can make another file.
    |
   */
  
  $app-&gt;singleton(
      Illuminate\Contracts\Debug\ExceptionHandler::class,
      App\Exceptions\Handler::class
  );
  
  $app-&gt;singleton(
      Illuminate\Contracts\Console\Kernel::class,
      App\Console\Kernel::class
  );
  
  $app-&gt;singleton(
      Illuminate\Contracts\Routing\ResponseFactory::class,
      Illuminate\Routing\ResponseFactory::class
  );
  
  
  /*
    |--------------------------------------------------------------------------
    | Register Middleware
    |--------------------------------------------------------------------------
    |
    | Next, we will register the middleware with the application. These can
    | be global middleware that run before and after each request into a
    | route or middleware that'll be assigned to some specific routes.
    |
   */
  // $app-&gt;middleware([
  //    App\Http\Middleware\ExampleMiddleware::class
  // ]);
  
  $app-&gt;routeMiddleware([
      'auth'        =&gt; App\Http\Middleware\Authenticate::class,
      'jwt.auth'    =&gt; Tymon\JWTAuth\Middleware\GetUserFromToken::class,
      'jwt.refresh' =&gt; Tymon\JWTAuth\Middleware\RefreshToken::class,
  ]);
  
  /*
    |--------------------------------------------------------------------------
    | Register Service Providers
    |--------------------------------------------------------------------------
    |
    | Here we will register all of the application's service providers which
    | are used to bind services into the container. Service providers are
    | totally optional, so you are not required to uncomment this line.
    |
   */
  
  $app-&gt;register(App\Providers\AppServiceProvider::class);
  $app-&gt;register(App\Providers\AuthServiceProvider::class);
  $app-&gt;register(App\Providers\EventServiceProvider::class);
  
  $app-&gt;register(Tymon\JWTAuth\Providers\LumenServiceProvider::class);
  /*
    |--------------------------------------------------------------------------
    | Load The Application Routes
    |--------------------------------------------------------------------------
    |
    | Next we will include the routes file so that they can all be added to
    | the application. This will provide all of the URLs the application
    | can respond to, as well as the controllers that may handle them.
    |
   */
  
  $app-&gt;group(['namespace' =&gt; 'App\Http\Controllers'], function ($app) {
      require __DIR__ . '/../app/Http/routes.php';
  });
  
  return $app;
  </code></pre>
  
  <p>My Model User -</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Auth\Authenticatable;
  use Laravel\Lumen\Auth\Authorizable;
  use Illuminate\Database\Eloquent\Model;
  use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
  use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
  use Tymon\JWTAuth\Contracts\JWTSubject;
  
  class User extends Model implements JWTSubject, AuthenticatableContract, AuthorizableContract {
  
      use Authenticatable,
          Authorizable;
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
      protected $fillable = [
          'name', 'email',
      ];
  
      /**
       * The attributes excluded from the model's JSON form.
       *
       * @var array
       */
      protected $hidden = [
          'password',
      ];
  
      public function getJWTIdentifier() {
          return $this-&gt;getKey();
      }
  
      public function getJWTCustomClaims() {
          return [];
      }
  
  }
  </code></pre>
  
  <p>My - JwtSubject -</p>
  
  <pre><code>&lt;?php
  
  /*
   * This file is part of jwt-auth.
   *
   * (c) Sean Tymon &lt;tymon148@gmail.com&gt;
   *
   * For the full copyright and license information, please view the LICENSE
   * file that was distributed with this source code.
   */
  
  namespace Tymon\JWTAuth\Contracts;
  
  interface JWTSubject
  {
      /**
       * Get the identifier that will be stored in the subject claim of the JWT.
       *
       * @return mixed
       */
      public function getJWTIdentifier();
  
      /**
       * Return a key value array, containing any custom claims to be added to the JWT.
       *
       * @return array
       */
      public function getJWTCustomClaims();
  }
  </code></pre>
  
  <p>My  function __construct</p>
  
  <p>class UserController extends Controller {</p>
  
  <pre><code>public $request;
  protected $jwt;
  
  public function __construct(Request $request, JWTAuth $jwt) {
      try {
          $this-&gt;request = $request;
          $this-&gt;jwt = $jwt;
      } catch (Exception $ex) {
          \Log::error("Error : " . $ex);
          $output = array('success' =&gt; false, 'result' =&gt; null, 'error' =&gt; $ex, 'error_key' =&gt; 'unhandled_exception');
          return new Response($output);
      }
  }
  </code></pre>
  
  <p>Please help me how can i get token using only Email.</p>