title: Laravel Passport Always unathenticated
body: <p>I've set up a new Laravel project and I'm planning to use Laravel Passport to manage the authentication of my api.</p>
  
  <p>I've got login and registration working, but showing details doesnt.</p>
  
  <p>I'm testing using postman making a post request to <code>/api/details</code> with the following data:</p>
  
  <pre><code>Authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjgwYmNhOGEzMTBmZjc2YTg0NTdkMTRjOTk0Y2VkNzMzODUwNDZkYjRhMzBhYjRjOTM0MWFlMGI4Y2I4MzRjMGU3MjY2ZjY5NjMwYTlmZjNmIn0.eyJhdWQiOiIxIiwianRpIjoiODBiY2E4YTMxMGZmNzZhODQ1N2QxNGM5OTRjZWQ3MzM4NTA0NmRiNGEzMGFiNGM5MzQxYWUwYjhjYjgzNGMwZTcyNjZmNjk2MzBhOWZmM2YiLCJpYXQiOjE1NTMxMTY4NjEsIm5iZiI6MTU1MzExNjg2MSwiZXhwIjoxNTg0NzM5MjYxLCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.I66xwDmnc5O7NmaiXDYLiZATDGOBnicDgA94VhX8OKJ8wcRnZ9g0vgMIZRPWEmIXqxfdffQ8FR3LA3iB-nzVZhzFoPg8Bu17T739dU7fqjiM7t9dWSo1X_xUL-sumunppTQz-mAubQTS3wEXzfX1o72Z2eOd4pK9XxQCetDaGGkMwFqEmwr7FFddR9oITO3_KABGDiyE8LZDqzVMBDKEamOFdtLuMhIdJKuBFxetPJYF9WWQNXEvOOhS_o_XYISummFle52qnmpkDEVrR8QxYiy6CaNZN7KFHs2eTdb84ovNWGldzbBat6W8wBa4SuMz6rRgYmNjlbZpCHLNtxMOe7O1hziBZOHgpiw_bdRs4gD03AEsQk-_ADCfKTwaS6g3jcXNkkOcNITxaLdJEfVPH_d6iGftJXZtF_wv_JIpWEtxF--dN28wtI1Jvjf7DbdkOYpDYii-aXJDYLZFtMAb5_nzGS1ohjvoG3bNhn5jz2ugJ5IoB7cOwb22Kkc7jz37SCkAPzKvgUwNACIJ3lVfvToW7WlQDLo2nwubV9KMYVPoKc30CGMM5sdaqvQCPSQQTB3OQbG9bSIfA1uuPAaK7WKjPLOU1G3DavUc6kr0WhxcQS2wteuheKz3T_i9frrgUoknqHC5Tr-Y-DioXZP56CUOSXyqd9ABYEMzHLqyBt8
  
  Content-Type: application/x-www-form-rurlencoded
  
  Accept: application/json
  </code></pre>
  
  <p>I run the login first and get returned the above token, but I always get the <code>{"message":"Unauthenticated."}</code> response.</p>
  
  <p>Here's my code:</p>
  
  <p>Api.php</p>
  
  <pre><code>&lt;?php
  /*
  |--------------------------------------------------------------------------
  | API Routes
  |--------------------------------------------------------------------------
  |
  | Here is where you can register API routes for your application. These
  | routes are loaded by the RouteServiceProvider within a group which
  | is assigned the "api" middleware group. Enjoy building your API!
  |
  */
  Route::post('login', 'API\UserController@login');
  Route::post('register', 'API\UserController@register');
  Route::group(['middleware' =&gt; 'auth:api'], function() {
      Route::post('details', 'API\UserController@details');
  });
  </code></pre>
  
  <p>AppServiceProvider.php</p>
  
  <pre><code>&lt;?php
  namespace App\Providers;
  use Laravel\Passport\Passport; 
  use Illuminate\Support\Facades\Gate; 
  use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
  use Carbon\Carbon;
  
  class AuthServiceProvider extends ServiceProvider 
  { 
      /** 
       * The policy mappings for the application. 
       * 
       * @var array 
       */ 
      protected $policies = [ 
          'App\Model' =&gt; 'App\Policies\ModelPolicy', 
      ];
  /** 
       * Register any authentication / authorization services. 
       * 
       * @return void 
       */ 
      public function boot() 
      { 
          $this-&gt;registerPolicies(); 
          Passport::routes(); 
  
          Passport::tokensExpireIn(Carbon::now()-&gt;addYears(20));
  
          Passport::refreshTokensExpireIn(Carbon::now()-&gt;addYears(20));
      } 
  }
  </code></pre>
  
  <p>Auth.php</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; 'web',
          '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; [
          'web' =&gt; [
              'driver' =&gt; 'session',
              'provider' =&gt; 'users',
          ],
          'api' =&gt; [
              'driver' =&gt; 'passport',
              'provider' =&gt; 'users',
          ],
      ],
      /*
      |--------------------------------------------------------------------------
      | 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,
          ],
          // 'users' =&gt; [
          //     'driver' =&gt; 'database',
          //     'table' =&gt; 'users',
          // ],
      ],
      /*
      |--------------------------------------------------------------------------
      | 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; [
          'users' =&gt; [
              'provider' =&gt; 'users',
              'email' =&gt; 'auth.emails.password',
              'table' =&gt; 'password_resets',
              'expire' =&gt; 60,
          ],
      ],
  ];
  </code></pre>
  
  <p>UsersController</p>
  
  <pre><code>&lt;?php
  namespace App\Http\Controllers\API;
  use Illuminate\Http\Request; 
  use App\Http\Controllers\Controller; 
  use App\User; 
  use Illuminate\Support\Facades\Auth; 
  use Validator;
  class UserController extends Controller 
  {
  public $successStatus = 200;
  /** 
       * login api 
       * 
       * @return \Illuminate\Http\Response 
       */ 
      public function login(){ 
          if(Auth::attempt(['email' =&gt; request('email'), 'password' =&gt; request('password')])){ 
              $user = Auth::user(); 
              $success['token'] =  $user-&gt;createToken('MyApp')-&gt; accessToken; 
              return response()-&gt;json(['success' =&gt; $success], $this-&gt; successStatus); 
          } 
          else{ 
              return response()-&gt;json(['error'=&gt;'Unauthorised'], 401); 
          } 
      }
  /** 
       * Register api 
       * 
       * @return \Illuminate\Http\Response 
       */ 
      public function register(Request $request) 
      { 
          $validator = Validator::make($request-&gt;all(), [ 
              'name' =&gt; 'required', 
              'email' =&gt; 'required|email', 
              'password' =&gt; 'required', 
              'c_password' =&gt; 'required|same:password', 
          ]);
  if ($validator-&gt;fails()) { 
              return response()-&gt;json(['error'=&gt;$validator-&gt;errors()], 401);            
          }
  $input = $request-&gt;all(); 
          $input['password'] = bcrypt($input['password']); 
          $user = User::create($input); 
          $success['token'] =  $user-&gt;createToken('MyApp')-&gt; accessToken; 
          $success['name'] =  $user-&gt;name;
  return response()-&gt;json(['success'=&gt;$success], $this-&gt; successStatus); 
      }
  /** 
       * details api 
       * 
       * @return \Illuminate\Http\Response 
       */ 
      public function details() 
      { 
          $user = Auth::user(); 
          return response()-&gt;json(['success' =&gt; $user], $this-&gt; successStatus); 
      } 
  }
  </code></pre>
  
  <p>User.php</p>
  
  <pre><code>&lt;?php
  namespace App;
  use Laravel\Passport\HasApiTokens;
  use Illuminate\Notifications\Notifiable;
  use Illuminate\Foundation\Auth\User as Authenticatable;
  class User extends Authenticatable
  {
    use HasApiTokens, Notifiable;
  /**
  * The attributes that are mass assignable.
  *
  * @var array
  */
  protected $fillable = [
  'name', 'email', 'password',
  ];
  /**
  * The attributes that should be hidden for arrays.
  *
  * @var array
  */
  protected $hidden = [
  'password', 'remember_token',
  ];
  }
  </code></pre>
  
  <p>Can someone point out how to get this working please?</p>
  
  <p><strong>Laravel verion: 5.8.5</strong></p>