Laravel 5.3 + Passport: always unauthenticated error

I'm always receiving "Unauthenticated error" when using Passport in my current project. That's what I did the lasts 3 days:

  • Install and configure Passport (as docs says)
  • Request a token (password grant token) with Postman
  • Request a protected route (auth:api middleware) with the token
  • Get `{ "error": "Unauthenticated." }`
  • Search and search and research
  • Get `{ "error": "Unauthenticated." }`

Then, I've installed a fresh L5.3 and a fresh DB and works fine. Even with my current DB!

I've tried all the solutions that I found without success ...

Can anyone help me? Any idea would be appreciated.


I had the same problem as you and looked everywhere to find a solution.

It appeared to be Apache's fault in my case. Apache was deleting the header "Authorization: Bearer TOKEN_HERE" so the auth:api wouldn't work as expected (getting 401 unauthorized).

We ended up trying adding to our .htaccess:

RewriteCond %{HTTP:Authorization} ^(.*)

RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

And it magically worked.

I really hope it helps, we spent a whole day trying many solutions, this is the one that worked for us.

Upgrade Guide - Laravel, 5.4, 5.3, 5.2 � 5.1 � 5.0 � 4.2. Icon. WARNING You're browsing the documentation for an old version of Laravel. Consider upgrading your project to Laravel 7.x. Laravel Vapor. Laravel Vapor is a serverless deployment platform for Laravel, powered by AWS. Launch your Laravel infrastructure on Vapor and fall in love with the scalable simplicity of serverless.

Which grant_type have you used to generate this token?

Possible resolutions are as follows

1: If you are using client credentials to generate your access_token, you have to turn on client_credentials, middleware as follows.

1.1 Add to the routeMiddleware in \App\Http\Kernel.php

'client_credentials'     => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class,

1.2 Use 'client_credentials' middleware in your route too.

Route::group(['prefix' => 'v1','middleware' => 'client_credentials'], function () {

    // Your routes here


2: For Grant Type Password

2.1 : Create a Password Grant Client

php artisan passport:client --password

2.2 : Request A token with following header fields

    'grant_type' => 'password',
    'client_id' => 'client-id',
    'client_secret' => 'client-secret',
    'username' => '',
    'password' => 'my-password',

End point /oauth/token

The token you get now should give you access to your api.

Errors & Logging - Laravel, If you are upgrading from Laravel 5.3 and using the pre-built Passport Vue components, you should make sure the Axios library is globally available to your � Laravel 5.3 is now released and available for everyone. Here is a quick look at some of these new features: Laravel Scout Laravel Scout is a driver based full-text search for Eloquent. Out of the box, it supports Algolia and because it’s driver based anyone in the community can create their own integration with other full-text search systems.

My problem was an omision, I'm building a GraphQL api and in the middleware line at the configuration file "graphql.php" I put

'middleware' => ['auth'],

when the correct way is:

'middleware' => ['auth:api'],

Laravel 5.3 is now released, The Laravel team is proud to announce the release of Laravel 5.3 and it's now available for everyone. The new features in 5.3 are focused on� Laravel 5.3 is now released September 09, 2016 / Eric L. Barnes The Laravel team is proud to announce the release of Laravel 5.3 and it’s now available for everyone. The new features in 5.3 are focused on improving developer speed by adding additional out of the box improvements for common tasks.

laravel-shift/laravel-5.3, Laravel 5.3 for Laravel Shift -. Contribute to laravel-shift/laravel-5.3 development by creating an account on GitHub. Laravel 5.3 framework has been just released. I won’t focus on new features about it right now, I will just make it clear how to install different versions of Laravel without a problem as for many especially new developers it causes problem.

Laravel 5.3 documentation — DevDocs, Laravel 5.3.30 API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more. Want to setup an OAuth2 server with API authentication in minutes, instead of days? Well, you're in luck. Laravel Passport has your back! In this episode, Taylor Otwell, himself, stops by to show you the goods.

Laravel 5.3 New Features and Updates ―, Guess, I'll have to wait for a couple of months to watch it on Youtube. That aside, this year's Laracon will be the stage for unveiling Laravel 5.3. Laravel 5.3 - image dimension validation rules example; Laravel 5.3 - import export csv and excel file into database; Laravel 5.3 Image Upload with Validation example; Laravel 5 create Custom Validation Rule example.

  • i guess you send token as authorization parameter in header according to documents about OAuth , but apache block this parameter and passport middleware cant authenticate your request, change authentication name to other thing such as token or key or everything except authorization. be successful
  • Thanks a lot @leo. you saved my day.