0

I have a problem to test the passport in laravel, when testo in postman gives me an error.

"message": "",
    "exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException",
    "file": "/data/www/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php",
    "line": 179,

routes/api.php

Route::group([
    'prefix'        => 'api',
    'middleware'    => ['auth.api']
], function () {
    Route::post('details', 'API\UserController@details');
});

UserController.php

    public function details()
{
    dd("Ijdsijds");
    $user = Auth::user();
    return response()->json(['success' => $user], $this->successStatus);
}

kernel.php

   protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
            'cors' => [
                \Barryvdh\Cors\HandleCors::class,
            ]
        ],
    ];

VerifyCRFSToken.php

protected $except = [
        //'authenticate'
        '/api/*'
    ];

Where am I going wrong? the route is listed in route: list

jrenk
  • 1,387
  • 3
  • 24
  • 46
Diegojj
  • 51
  • 1
  • 9
  • 3
    What is the route you are sending to with your postman? – Chin Leung Jul 18 '18 at 13:58
  • you have placed a middleware `'middleware' => ['auth.api']`, what does that do? Are you sending along any API key (for example) with the request? – Lucky Soni Jul 18 '18 at 15:16
  • You shouldnt really use dd command with postman it is obly designed for browsers. Just return a json or string. Api prefix isnt needed when writing routes on api.php its already set. This might be your problem. – berkay kılıç Jul 18 '18 at 15:19

1 Answers1

0

As you are using routes/api.php which is stateless so you will not get any session value (here Auth).

To get value Either use Passport Helpful link

or Use JWT

Niklesh Raut
  • 34,013
  • 16
  • 75
  • 109
  • I am already using the passport, I am testing the api via postman and it returns me this error, I already tried everything here – Diegojj Jul 18 '18 at 14:13