This is a Laravel project that shows how to use JSON Web token for API Tokenization. Implemenation user authentication and authorization as well as Task CRUD functionality.
NOTE: You must have PHP >=8.2, composer and Mysql before you can execute this project
Step 1: Clone git repo
git clone git@github.com:Guzbyte-tech/Simple_jwt_auth_with_laravel.git
Step 2: cd into the project
cd Simple_jwt_auth_with_laravel
Step 3: Run the composer install command
composer install
Step 4: Copy and setup .env file
cp .env.example .env
Step 5: Generate Application key
php artisan key:generate
Step 6: Create Database and update database credentials in .env file
DB_DATABASE=interview
DB_USERNAME=root
DB_PASSWORD=
Step 7: Run the following command to set JWT_SECRET in the .env file
php artisan jwt:secret
Then, run the command below to migrate database.
php artisan migrate
Step 8: Update the .env file with your GOOGLE_CLIENT_ID and SECRET to enable OAuth2 sign and register with Google. you can do that https://console.cloud.google.com/. In your .env file set the following with the right credentials
GOOGLE_CLIENT_ID="xxxxx"
GOOGLE_CLIENT_SECRET="xxxx"
(Optional only on localhost) Then goto terminal and serve Application using the command
php artisan serve
Step 9: Since this is on a local server set Google Callback uri to http://127.0.0.1:8000/api/v1/google/callback . To test on live server replace http://127.0.0.1:8000 with e.g https://example.com
Step 9: Run the command below to generate swagger Documentation.
php artisan l5-swagger:generate
Goto http://127.0.0.1:8000/api/v1/documentation to view API documentation with swagger.
THATS IT :)