mercredi 31 janvier 2018

“Unauthenticated” when consuming own API with passport?

I have installed passport as the documentation instructed and added this line the 'web' middleware:

'web' => [
    // Other middleware...
    \Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
],

and now , Iam trying to get some data using datatable ( datatables.net ) with ajax:

api.php

Route::group(['prefix' => 'v1', 'middleware' => 'auth:api'], function()
{
  Route::get('/itemsData', 'DataController@getItemsData')->name('api.getItemsData');

});

in blade:

<script>
    $(document).ready(function() {
        $('#Table').DataTable({
            "order": [],
            "processing": true,
            "serverSide": true,
            "ajax": "",
            "columns": [{
                "data": "name"
            }, {
                "data": "created_at"
            }],
        });
    });
</script>

but Iam getting this as a response:

{"message":"Unauthenticated."}



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

Aucun commentaire:

Enregistrer un commentaire