This is an API REST of fruits with Laravel and Laravel Passport to request Tokens on API calls. Frontend of the API is on carloso2103/Fruits_Crud_Frontend.
- composer install
- Duplicate .env.example on .env and changge your data (db, URL of front (CORS), etc) .
- php artisan key:generate
- php artisan migrate --seed
- php artisan passport:install and save ids and secrets on.
- Create a user on your db.
- On your server /oauth/autorize with this form data : client_id, redirect_uri, response_type:'code' and scope.
- Create a passport client with: php artisan passport:client (Asign to the id of user created).
- php artisan tinker
- $user = App\User::find(1); $token = $user->createToken('Token Name')->accessToken; Copy the token.
- On vendor/fruitcake/laravel-cors/config/cors add to paths and allowed_origins environment variables(URL and SECURE_URL).
- On environment.ts of frontend after production:false, add API_URL:"your url" and token:"your token".