title: Laravel API using JWT Auth Credential (username/email)
body: <p>I'm using laravel with JWT Auth to connect my laravel project to mobile, this is my api controller at laravel </p>
  
  <pre><code>public function login(Request $request) {
      $credentials = $request-&gt;only('email', 'password');
  
      try {
          // attempt to verify the credentials and create a token for the user
          if (! $token = JWTAuth::attempt($credentials)) {
              return response()-&gt;json(['error' =&gt; 'invalid_credentials'], 401);
          }
      } catch (JWTException $e) {
          // something went wrong whilst attempting to encode the token
          return response()-&gt;json(['error' =&gt; 'could_not_create_token'], 500);
      }
  
      // all good so return the token
      $user = Sentry::authenticate($credentials, false);
  
      return response()-&gt;json([
          'code' =&gt; '200',
          'message' =&gt; 'success',
          'last_updated' =&gt; $user-&gt;updated_at-&gt;format("Y-m-d\TH:i:s\Z"),
          'data' =&gt; [
              'id' =&gt; $user-&gt;id,
              'first_name' =&gt; $user-&gt;first_name,
              'last_name' =&gt; $user-&gt;last_name,
              'email' =&gt; $user-&gt;email,
              'username' =&gt; $user-&gt;username,
              'token' =&gt; $token
          ]
      ]);
  }
  </code></pre>
  
  <p>but how to set the credentials using email or username with this JWT?</p>