Laravel 5.3 Personal access token 500

陌路散爱 提交于 2019-12-06 03:23:32

问题


I'm trying to set up my custom API with Passport (well, I'm already halfway through, just need to build my authentication). Whenever I'm trying to create a personal access token from my Passport dashboard (/home route), I get a 'Whoops, something went wrong!' error.

This comes from my Vue component (PersonalAccessTokens.vue), and my console logs me a 500 internal server error at the Post route for storing personal access tokens...

\Laravel\Passport\Http\Controllers\PersonalAccessTokenController@store is the method responsible but I can't seem to find something outof the ordinary as I did exactly follow the Laracasts video about Passport

Anyone else experiencing this problem ?

TIA!


回答1:


I figured it out.

Apparently it can't read my personal access token client, that you should generate when setting up Passport by using the command: php artisan passport:install

Running this command solves my problem.

Reference: https://laracasts.com/discuss/channels/laravel/create-personal-access-token-in-laravel-passport-is-failing




回答2:


A little more info on this as I've been having the same problem. You need to run:

php artisan passport:install

each time you refresh your migrations by doing:

php artisan migrate:refresh

To deal with this I've just added a script to package.json which uses npm-run-all so I can do it in one command:

"scripts": {
  // Other scripts
  "migrate:refresh": "php artisan migrate:refresh",
  "passport:install": "php artisan passport:install",
  "db:refresh": "npm-run-all --sequential migrate:refresh passport:install"
}

Now I can just do:

npm run db:refresh



来源:https://stackoverflow.com/questions/40563147/laravel-5-3-personal-access-token-500

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!