This is a simple api Microblogging project.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
"laravel/framework": "5.8.*",
We need to install Laravel Passport package via the composer dependency manager.
"laravel/passport": "^7.3",
composer require laravel/passport
Laravel Passport requires some steps to set up properly.
You need to add Se rvice Provider in the config/app.php file. So, open the file and add the Service Provider in the providers array.
'providers' => [
....
Laravel\Passport\PassportServiceProvider::class,
]
Setup database credentials in .env file.
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=xxxx
DB_USERNAME=xxxx
DB_PASSWORD=xxxx
Laravel Passport comes up with migration for passport tables that are required to be in our database. Passport Migrations are used for storing tokens and client information. Run migration command to migrate schemas to your database and seed data for testing.
php artisan migrate:refresh --seed
Next, it is required to install passport using the command below. It will generate encryption keys required to generate secret access tokens and every time you migrate database you need to run this command.
php artisan passport:install
Note: ignore dublication error in follower_following table seed its due to random generation.
To create the symbolic link, you may use the storage:link Artisan command:
php artisan storage:link
Run server.
php artisan serve
You can login with seeded data the default password is 123456
When testing Details API or any API that requires a user to be authenticated, you need to specify two headers. You must specify access token as a Bearer token in the Authorization header. Basically, you have to concatenate the access token that you received after login and registration with the Bearer followed by a space.
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer '. $accessToken,
]
Route: POST http://127.0.0.1:8000/api/register You need body form data name,email,password,img(file) and make sure of that
'headers' => [
'Accept' => 'application/json',
]
Route: POST http://127.0.0.1:8000/api/login
Route: GET http://127.0.0.1:8000/api/users
Route: GET http://127.0.0.1:8000/api/user
Route: POST http://127.0.0.1:8000/api/users/{profileId}/follow
Route: POST http://127.0.0.1:8000/api/users/{profileId}/unfollow
Route: GET http://127.0.0.1:8000/api/timeline
Route: POST http://127.0.0.1:8000/api/tweets
Route: GET http://127.0.0.1:8000/api/tweets
Route: GET http://127.0.0.1:8000/api/tweets/{tweet}
Route: DELETE http://127.0.0.1:8000/api/tweets/{tweet}