0

在我安装 laravel 5.4 并添加护照包后,我在控制台中收到这些错误

Failed to load resource: the server responded with a status of 500 (Internal Server Error)
app.js:11476 Uncaught (in promise) Error: Request failed with status code 500
    at createError (app.js:11476)
    at settle (app.js:11975)
    at XMLHttpRequest.handleLoad (app.js:11315)
http://localhost:8000/oauth/personal-access-tokens Failed to load resource: the server responded with a status of 500 (Internal Server Error)
app.js:11476 Uncaught (in promise) Error: Request failed with status code 500
    at createError (app.js:11476)
    at settle (app.js:11975)
    at XMLHttpRequest.handleLoad (app.js:11315)

这是我的 composer.josn

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
    "php": ">=5.6.4",
    "laravel/framework": "5.4.*",
    "laravel/passport": "^2.0",
    "laravel/tinker": "~1.0"
},
"require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~5.0"
},
"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "App\\": "app/"
    }
},
"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    }
},
"scripts": {
    "post-root-package-install": [
        "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ],
    "post-install-cmd": [
        "Illuminate\\Foundation\\ComposerScripts::postInstall",
        "php artisan optimize"
    ],
    "post-update-cmd": [
        "Illuminate\\Foundation\\ComposerScripts::postUpdate",
        "php artisan optimize"
    ]
},
"config": {
    "preferred-install": "dist",
    "sort-packages": true
}

}

这是我的 home.blade.php

@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
    <div class="col-md-8 col-md-offset-2">

            <passport-clients></passport-clients>
            <passport-authorized-clients></passport-authorized-clients>
            <passport-personal-access-tokens></passport-personal-access-tokens>
    </div>
</div>

@endsection

这是我的 app.js 文件

require('./bootstrap');



Vue.component(
  'passport-clients',
   require('./components/passport/Clients.vue')
);

Vue.component(
'passport-authorized-clients',
require('./components/passport/AuthorizedClients.vue')
);

Vue.component(
'passport-personal-access-tokens',
require('./components/passport/PersonalAccessTokens.vue')
);
Vue.component('example', require('./components/Example.vue'));

const app = new Vue({
el: '#app'
});

在我登录并尝试获取个人令牌后,我收到错误,当我看到控制台时,我发现内部服务器错误,我不知道我错过了什么

4

1 回答 1

0

我发现我忘记添加使用 HasApiTokens;在类声明后的用户模型中

namespace App;
use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

 class User extends Authenticatable
{
//that was missing 
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',
];

}

于 2017-02-03T14:54:30.690 回答