At first, I was only relying on the documentation and also laracasts video to setup Passport. But as I go through, some undocumented steps are missing that I had to google it. Luckily I found a a solution from stackoverflow, and my project is back on schedule. Perhaps some of you experiencing the same problem, as I did, here are 10 easy direct steps you can follow (copy & paste) along without any hassles.
Ready?
Here we go...
- Run 
composer require laravel/passportfrom your shell (command prompt on Windows). - Open the config/app.php file, and add 
Laravel\Passport\PassportServiceProvider::classsomewhere inside the $providers array - Run 
php artisan:migratefrom your shell. - Still at your shell, run 
php artisan passport:install. - Open the User model class, it is located at app/User.php, and add 
use Laravel\Passport\HasApiTokens;somewhere between the namespace and the class declaration, also use this HasApiTokens trait inside the class like souse HasApiTokens, Notifiable;. - Open the app/Providers/AuthServiceProvider.php file, and add 
use Laravel\Passport\Passport;
between the namespace and the class declaration, and also add this linePassport::routes();inside theboot()function. - Open the config/auth.php file and change the API driver from token to passport
 - If you intend to consume your API from the same Laravel application, simply open the app/Http/Kernel.php file, and add 
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::classinside the$webarray. - Run 
php artisan passport:clientto create an Oauth2 client for your API. From this step, you will get a personal access token. - Use the personal access token you get from step #9 and use it to hit your API.
 
- Authorization : "Bearer <token>"
 - Accept : application/json
 
Happy coding guys ^_^
Some other usefull sources:
ReplyDeletehttps://scotch.io/@neo/getting-started-with-laravel-passport
https://vuejs.org/v2/guide/events.html#Method-Event-Handlers
https://github.com/mzabriskie/axios
http://codeheaven.io/how-to-use-axios-as-your-http-client/
https://laracasts.com/discuss/channels/laravel/laravel-53-passport-cross-domain-error
https://github.com/barryvdh/laravel-cors