Feb 20, 2016
This tutorial is based on Laravel 5 token based Authentication (OAuth 2.0) & Dingo Wiki.They both have some bugs and I fixed them.
1.Install a new Laravel Project and of coures you have to set up your database.
2.Modify composer.json
and run composer update
to include extra packages.
3.Add new providers in your config/app.php
file.
And this lines to the aliases array:
4.Add new $middleware
& $routeMiddleware
in your app/Http/Kernel.php
file.
5.Run php artisan vendor:publish
and php artisan migrate
in your project folder.
Add the following settings in you .env
file:
6.Now is your routes.php
file.
7.You’ll need a client to make your oauth2 server runs.
In the database find the oauth_client
s Table , insert new record to it ,or you can use the following SQL code in phpMyAdmin:
8.Edit your Api Controllers.
You can add models named Book,Post,User as you like,here is an example:
9.Test your server now!
We are almost done.Now you need to test the server you’ve just set up.We can use tools like PostMan to emulate requests to your server.
Back To Top