vendredi 28 juillet 2017

Laravel Passport Authentication Issues: Always returns unauthenticated

After looking through dozens of answers, I still can't find a solution to his issue.

Problem

Every time I make an authenticated request, the response is {"error":"Unauthenticated."}

Routes

Here are the routes I've been testing with.

use Illuminate\Http\Request;
use Laravel\Passport\Http\Middleware\CheckClientCredentials;

Route::get('/test', function () {
    return 'Hello World';
})->middleware('auth:api');

Route::middleware('auth:api')->get('/test2', function (Request $request) {
    return 'Hello World';
});

Setup

I set this project up as the tutorial instructed, and used the PHP artisan commands to construct my database. I then began to use Postman test it.

The token is acquired using a grant_type: password, client credentials, and user credentials. A "Bearer " . $token type is then granted.

What I've Done and Tested

I've checked the .htaccess, token expiration date, namespaces, and other common errors. I setup a test function to check my header information. The results are posted below. For some reason, the issue persists. There also aren't any actual errors... No error.log updates, just a response from the API letting me know the user is not authenticated.

 array:12 [
    "cookie" => array:1 [
        0 => "XSRF-TOKEN=eyJpdiI6IkwrNGxLOGVtc1M1Y2lYeUMraldTK3c9PSIsInZhbHVlIjoibHRzdVo3bFVJOFhuMDJvZ3RoNEYxK1NsdmhRenZkbmp5b2xuYXVzWTdIUGJ2WGFUbXBiK1JFQ0VNSVlNbjdIbHVmcndmKzBaMzVJbGkxelZFdllhM0E9PSIsIm1hYyI6ImZhMDJjZDIwNDgxMTRkMDdjYTBkYmMwODc4YzQ4ZmM3OGFkZTI3NzY1ZDA5NTAyODhkYjRlNTY1OGUyMTYyNGEifQ%3D%3D;  laravel_session=eyJpdiI6Im5hTnVLS3cyc1BzQldudkN2bFNcLzZRPT0iLCJ2YWx1ZSI6IjIwXC8yRkM3Sk4rWkg0ZFFlaG9RYVErc2ZJT0taSHoxOTU3UVpxejdPZ2MzcHBSc2FCd1NweEZwU2kzQXUxZ1VCVmY1dzZIZldFb2J5QXkwMFwvZmpId1E9PSIsIm1hYyI6ImQxZDIzOGQ0NzllOTg4NmZmZDk2NGI1NDNhMzcwNmI1MWE2MzY0YWIzZTgxZjYzOTAxYjhlMWQ1ZTExNzBiMTEifQ%3D%3D"
    ]
    "accept-language" => array:1 [
        0 => "en-US,en;q=0.8,fr;q=0.6"
    ]
    "accept-encoding" => array:1 [
        0 => "gzip, deflate, sdch"
    ]
    "postman-token" => array:1 [
        0 => "864e4343-e8f1-2efd-1a75-11660313ba3d"
    ]
    "authorization" => array:1 [
        0 => "Bearer 0dea6edd3f655463c4e19cf26ef10755bcfbff5dcdbe44cd44c1d7a84c250c359c65f064737752e6"
    ]
    "cache-control" => array:1 [
        0 => "no-cache"
    ]
    "accept" => array:1 [
        0 => "application/json"
    ]
    "connection" => array:1 [
        0 => "close"
    ]
    "x-http-proto" => array:1 [
        0 => "HTTP/1.1"
    ]
]

Suspicions

At this point, I think I just must be using some of the tools wrong. I'm hoping it is a simple mistake, but I'm just completely at a loss as to what it could be.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2vfu6HM
via IFTTT

Aucun commentaire:

Enregistrer un commentaire